Skip to content

Commit

Permalink
Core: Refine yield for high performance timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 11, 2021
1 parent 435700b commit 387cddb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ unsigned long long _st_stat_sched_s = 0;
unsigned long long _st_stat_thread_run = 0;
unsigned long long _st_stat_thread_idle = 0;
unsigned long long _st_stat_thread_yield = 0;
unsigned long long _st_stat_thread_yield2 = 0;
#endif


Expand Down Expand Up @@ -559,18 +560,22 @@ void st_thread_yield()
{
_st_thread_t *me = _ST_CURRENT_THREAD();

#ifdef DEBUG
++_st_stat_thread_yield;
#endif

/* Check sleep queue for expired threads */
_st_vp_check_clock();

// 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;
++_st_stat_thread_yield2;
#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);
Expand Down

1 comment on commit 387cddb

@winlinvip
Copy link
Member Author

@winlinvip winlinvip commented on 387cddb Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ossrs/srs#2194 (comment) 改进了yield的触发条件。

Please sign in to comment.