本文整理汇总了C++中chRegFirstThread函数的典型用法代码示例。如果您正苦于以下问题:C++ chRegFirstThread函数的具体用法?C++ chRegFirstThread怎么用?C++ chRegFirstThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chRegFirstThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmd_threads
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES};
uint64_t busy = 0, total = 0;
Thread *tp;
(void)argv;
if (argc > 0) {
chprintf(chp, "Usage: threads\r\n");
return;
}
chprintf(chp, "name addr stack prio refs state time\r\n");
chprintf(chp, "--------------------------------------------------------\r\n");
tp = chRegFirstThread();
do {
chprintf(chp, "%12s %.8lx %.8lx %4lu %4lu %9s %lu\r\n",
chRegGetThreadName(tp),
(uint32_t)tp, (uint32_t)tp->p_ctx.r13,
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
states[tp->p_state], (uint32_t)tp->p_time);
if(tp->p_prio != 1) {
busy += tp->p_time;
}
total += tp->p_time;
tp = chRegNextThread(tp);
} while (tp != NULL);
chprintf(chp, "CPU Usage: %ld%%\r\n", busy*100/total);
}
示例2: cmd_threads
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
static const char *states[] = {
"READY",
"CURRENT",
"SUSPENDED",
"WTSEM",
"WTMTX",
"WTCOND",
"SLEEPING",
"WTEXIT",
"WTOREVT",
"WTANDEVT",
"SNDMSG",
"WTMSG",
"FINAL"
};
Thread *tp;
char buf[60];
(void)argv;
if (argc > 0) {
shellPrintLine(chp, "Usage: threads");
return;
}
shellPrintLine(chp, " addr stack prio refs state time");
tp = chRegFirstThread();
do {
siprintf(buf, "%8lx %8lx %4u %4i %9s %u",
(uint32_t)tp, (uint32_t)tp->p_ctx.r13,
(unsigned int)tp->p_prio, tp->p_refs - 1,
states[tp->p_state], (unsigned int)tp->p_time);
shellPrintLine(chp, buf);
tp = chRegNextThread(tp);
} while (tp != NULL);
}
示例3: THD_FUNCTION
static THD_FUNCTION(ThreadMonitor, arg)
{
(void)arg;
chRegSetThreadName("Monitor");
uint32_t run_offset, irq_ticks = 0, total_ticks;
thread_t* tp = NULL;
DWT->CTRL |= DWT_CTRL_EXCEVTENA_Msk;
while (TRUE)
{
tp = chRegFirstThread();
do {
tp->runtime = 0;
tp->irqtime = 0;
tp = chRegNextThread(tp);
} while (tp != NULL);
irq_ticks = 0;
run_offset = DWT->CYCCNT;
/* Populate load data */
chThdSleepMilliseconds(1000);
/* Convert to systick time base */
total_ticks = (DWT->CYCCNT - run_offset) / (STM32_SYSCLK/CH_CFG_ST_FREQUENCY);
tp = chRegFirstThread();
do {
irq_ticks += tp->irqtime;
tp = chRegNextThread(tp);
} while (tp != NULL);
tp = chRegFirstThread();
do {
tp->pct = ((tp->runtime*10000)/total_ticks) | RUNNING(tp);
tp = chRegNextThread(tp);
} while (tp != NULL);
irq_pct = ((irq_ticks*10000)/total_ticks);
}
return;
}
示例4: regfind
static bool regfind(thread_t *tp) {
thread_t *ftp;
bool found = false;
ftp = chRegFirstThread();
do {
found |= ftp == tp;
ftp = chRegNextThread(ftp);
} while (ftp != NULL);
return found;
}
示例5: regfind
static bool_t regfind(Thread *tp) {
Thread *ftp;
bool_t found = FALSE;
ftp = chRegFirstThread();
do {
found |= ftp == tp;
ftp = chRegNextThread(ftp);
} while (ftp != NULL);
return found;
}
示例6: rtos_mon_periodic_arch
// Fill data structure
void rtos_mon_periodic_arch(void)
{
int i;
rtos_mon.core_free_memory = chCoreGetStatusX();
rtos_mon.heap_free_memory = 0;
rtos_mon.thread_counter = 0;
// loop threads to find idle thread
// store info on other threads
thread_t *tp;
float sum = 0.f;
rtos_mon.thread_name_idx = 0;
tp = chRegFirstThread();
do {
// add beginning of thread name to buffer
for (i = 0; i < RTOS_MON_NAME_LEN-1 && tp->p_name[i] != '\0'; i++) {
rtos_mon.thread_names[rtos_mon.thread_name_idx++] = tp->p_name[i];
}
rtos_mon.thread_names[rtos_mon.thread_name_idx++] = ';';
// store free stack for this thread
rtos_mon.thread_free_stack[i] = get_stack_free(tp);
// store time spend in thread
thread_p_time[rtos_mon.thread_counter] = tp->p_time;
sum += (float)(tp->p_time);
// if current thread is 'idle' thread, store its value separately
if (tp == chSysGetIdleThreadX()) {
idle_counter = (uint32_t)tp->p_time;
}
// get next thread
tp = chRegNextThread(tp);
// increment thread counter
rtos_mon.thread_counter++;
} while (tp != NULL && rtos_mon.thread_counter < RTOS_MON_MAX_THREADS);
// store individual thread load (as centi-percent integer)
for (i = 0; i < rtos_mon.thread_counter; i ++) {
rtos_mon.thread_load[i] = (uint16_t)(10000.f * (float)thread_p_time[i] / sum);
}
// assume we call the counter once a second
// so the difference in seconds is always one
// NOTE: not perfectly precise
// FIXME: add finer resolution than seconds?
rtos_mon.cpu_load = (1 - (float)(idle_counter - last_idle_counter) / CH_CFG_ST_FREQUENCY) * 100;
last_idle_counter = idle_counter;
}
示例7: chRegFirstThread
/**
* @brief Confirms that a pointer is a valid thread pointer.
* @note The reference counter of the found thread is increased by one so
* it cannot be disposed incidentally after the pointer has been
* returned.
*
* @param[in] tp pointer to the thread
* @return A pointer to the found thread.
* @retval NULL if a matching thread has not been found.
*
* @api
*/
thread_t *chRegFindThreadByPointer(thread_t *tp) {
thread_t *ctp;
/* Scanning registry.*/
ctp = chRegFirstThread();
do {
if (ctp == tp) {
return ctp;
}
ctp = chRegNextThread(ctp);
} while (ctp != NULL);
return NULL;
}
示例8: cmd_threads
/**
* This methods prints all threads and their total times
*/
static void cmd_threads(void) {
#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
static const char *states[] = { THD_STATE_NAMES };
Thread *tp;
print(" addr stack prio refs state time\r\n");
tp = chRegFirstThread();
do {
print("%.8lx [%.8lx] %4lu %4lu %9s %lu %s\r\n", (uint32_t) tp, 0, (uint32_t) tp->p_prio,
(uint32_t) (tp->p_refs - 1), states[tp->p_state], (uint32_t) tp->p_time, tp->p_name);
tp = chRegNextThread(tp);
} while (tp != NULL);
#endif
}
示例9: send_thread_states
void send_thread_states()
{
thread_t *tp = chRegFirstThread();
while (tp) {
msg_thread_state_t tp_state;
u16 cpu = 1000.0f * tp->p_ctime / (float)g_ctime;
tp_state.cpu = cpu;
tp_state.stack_free = check_stack_free(tp);
strncpy(tp_state.name, chRegGetThreadNameX(tp), sizeof(tp_state.name));
sbp_send_msg(SBP_MSG_THREAD_STATE, sizeof(tp_state), (u8 *)&tp_state);
tp->p_ctime = 0; /* Reset thread CPU cycle count */
tp = chRegNextThread(tp);
}
g_ctime = 0;
}
示例10: cmd_threads
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {CH_STATE_NAMES};
thread_t *tp;
(void)argv;
if (argc > 0) {
chprintf(chp, "Usage: threads\r\n");
return;
}
chprintf(chp, " addr stack prio refs state time\r\n");
tp = chRegFirstThread();
do {
chprintf(chp, "%08lx %08lx %4lu %9s\r\n",
(uint32_t)tp, (uint32_t)tp->ctx.sp,
(uint32_t)tp->prio, states[tp->state]);
tp = chRegNextThread(tp);
} while (tp != NULL);
}
示例11: send_thread_states
void send_thread_states()
{
Thread *tp = chRegFirstThread();
while (tp) {
msg_thread_state_t tp_state;
u16 cpu = 1000.0f * tp->p_ctime / (float)g_ctime;
tp_state.cpu = cpu;
tp_state.stack_free = check_stack_free(tp);
strncpy(tp_state.name, chRegGetThreadName(tp), sizeof(tp_state.name));
sbp_send_msg(MSG_THREAD_STATE, sizeof(tp_state), (u8 *)&tp_state);
/* This works because chThdGetTicks is actually a define that pulls out a
* value from a struct, hopefully if that fact changes then this statement
* will no longer compile. */
tp->p_ctime = 0;
tp = chRegNextThread(tp);
}
g_ctime = 0;
}
示例12: cmd_threads
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {THD_STATE_NAMES};
Thread *tp;
(void)argv;
if (argc > 0) {
chprintf(chp, "Usage: threads\r\n");
return;
}
chprintf(chp, " addr stack prio refs state time\r\n");
tp = chRegFirstThread();
do {
chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n",
(uint32_t)tp, (uint32_t)tp->p_ctx.r13,
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
states[tp->p_state], (uint32_t)tp->p_time);
tp = chRegNextThread(tp);
} while (tp != NULL);
}
示例13: cmd_threads
/*! \brief Show running threads
*
* @param chp
* @param argc
* @param argv
*/
void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)chp;
static const char *states[] = {THD_STATE_NAMES};
Thread *tp;
(void)argv;
if (argc > 0) {
SHELLDBG("Usage: threads\r\n");
return;
}
SHELLDBG("addr\t\tstack\t\tprio\trefs\tstate\t\ttime\tname\r\n");
tp = chRegFirstThread();
do {
SHELLDBG("%.8lx\t%.8lx\t%4lu\t%4lu\t%9s\t%lu\t%s\r\n",
(uint32_t)tp, (uint32_t)tp->p_ctx.r13,
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
states[tp->p_state], (uint32_t)tp->p_time, tp->p_name);
tp = chRegNextThread(tp);
} while (tp != NULL);
}
示例14: cmd_threads
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[])
{
static const char *states[] = {CH_STATE_NAMES};
thread_t *tp;
(void)argv;
if (argc > 0) {
chprintf(chp, "Usage: threads\r\n");
return;
}
chprintf(chp, " addr pc stack prio refs state name\r\n");
tp = chRegFirstThread();
do {
chprintf(chp, " %-8lx %-8lx %-8lx %4lu %4lu %-12s %-10s\r\n",
(uint32_t)tp, (uint32_t)tp->p_ctx.r13->lr, (uint32_t)tp->p_ctx.r13,
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
states[tp->p_state],
tp->p_name);
tp = chRegNextThread(tp);
} while (tp != NULL);
}
示例15: cmd_threads
static void cmd_threads( int argc, char *argv[] )
{
static const char *states[] = { CH_STATE_NAMES };
thread_t *tp;
(void)argv;
if( argc > 0 )
{
usage( "threads" );
return;
}
chprint( " addr stack prio refs state time\r\n" );
tp = chRegFirstThread();
do
{
chprint( "%08lx %08lx %4lu %4lu %9s\r\n",
(uint32_t)tp, (uint32_t)tp->p_ctx.r13,
(uint32_t)tp->p_prio, (uint32_t)( tp->p_refs - 1 ),
states[tp->p_state]);
tp = chRegNextThread( tp );
} while( tp != NULL );
}