|
|
@ -66,6 +66,7 @@ unsigned long long _st_stat_sched_s = 0;
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long long _st_stat_thread_run = 0;
|
|
|
|
unsigned long long _st_stat_thread_run = 0;
|
|
|
|
unsigned long long _st_stat_thread_idle = 0;
|
|
|
|
unsigned long long _st_stat_thread_idle = 0;
|
|
|
|
|
|
|
|
unsigned long long _st_stat_thread_yield = 0;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -554,6 +555,31 @@ void _st_vp_check_clock(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void st_thread_yield()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_st_thread_t *me = _ST_CURRENT_THREAD();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If not thread in RunQ to yield to, ignore and continue to run.
|
|
|
|
|
|
|
|
if (_ST_RUNQ.next == &_ST_RUNQ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
++_st_stat_thread_yield;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Check sleep queue for expired threads */
|
|
|
|
|
|
|
|
_st_vp_check_clock();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Append thread to the tail of RunQ, we will back after all threads executed.
|
|
|
|
|
|
|
|
me->state = _ST_ST_RUNNABLE;
|
|
|
|
|
|
|
|
_ST_ADD_RUNQ(me);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Yield to other threads in the RunQ.
|
|
|
|
|
|
|
|
_ST_SWITCH_CONTEXT(me);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void st_thread_interrupt(_st_thread_t *thread)
|
|
|
|
void st_thread_interrupt(_st_thread_t *thread)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* If thread is already dead */
|
|
|
|
/* If thread is already dead */
|
|
|
|