Re: Multitasking in Mac OS Gets 100% CPU
- Posted by jimcbrown (admin) Nov 06, 2012
- 1462 views
ghaberek said...
Interestingly, checking gnome-system-monitor with sleep(1) the "Waiting Channel" column displays hrtimer_nanosleep, but with sleep(0) it simply shows "0". Is the sleep() function not calling "nanosleep" when we pass 0 as a parameter?
-Greg
Looks like we have a bug in Wait() in be_task.c (which is used to implement the sleep() routine).
We have code in there to busy-wait if we are attempting to sleep in fractional sections, and the fractions are too small - but we also have a check so if we're sleeping for less than 1 second we just busy-wait it out.
I think this was done back when we supported DOS so we could sleep for fractional seconds from DOS apps...