ponyc icon indicating copy to clipboard operation
ponyc copied to clipboard

Don't call "sleep" for schedulers that shouldn't yield

Open SeanTAllen opened this issue 3 years ago • 0 comments

Prior to this change, scheduler threads that been waiting for work for 10000000 or more cycles would always call SleepEx/nanosleep regardless of the value of yield.

When the number of cycles was at least 10000000 and no more than 10000000000, this would have sleep called with a zero value. On both Windows and Posix, calling with a 0 value causes the thread to yield.

We were yielding regardless of yield value. Yield was only controlling if we would yield for more than our timeslice. It wasn't preventing the scheduler thread from giving up its current timeslice and being rescheduled at the kernel's leisure.

The code has been updated to only call sleep when yields are requested.

SeanTAllen avatar Aug 07 '22 22:08 SeanTAllen