in reply to Re: Re: Re: Re: I want to forfeit my timeshare
in thread I want to forfeit my timeshare
In Win32, which I'm most familar with, the sleep primitive is naturally rounded off to the timeslice boundary. That's because it's between time slices that it updates the thread's ready status if the time expired since the last time it checked. I think that's such a natural way of implementing it that it would do this on any OS, more or less.
So, sleep(0.0000001) would probably naturally give up the timeslice but stay on the ready list. In Win32, threads at the same priority are round-robin.
If an OS rounds =down= and decides not to sleep at all, then a more carefully chosen value of X would still work! Look up the quantum length and use that. It will expire midway through the next slice, but will not be taken as 0.
In general, sleep(qsize) will do exactly what you are asking for. sleep(very_small_value) probably does so, too.
—John
|
|---|