Re: IOLockSleepDeadline example in docu is wrong (won't compile)
Re: IOLockSleepDeadline example in docu is wrong (won't compile)
- Subject: Re: IOLockSleepDeadline example in docu is wrong (won't compile)
- From: Shaun Wexler <email@hidden>
- Date: Wed, 5 Sep 2007 14:20:42 -0700
On Sep 5, 2007, at 2:10 PM, Shaun Wexler wrote:
IODelay could have been implemented as an inline spin loop which
reads the timebase registers, but it was not, thus the
documentation is somewhat misleading.
There is no underlying difference between IOSleep and IODelay
functions, except for the granularity of their argument (mS vs
µS). They both call down to clock_delay_until(), which sleeps the
calling thread if preemption is enabled or the sleep time is longer
than the duration of (8x) context switches, etc.
That should read "and", not "or".
Use IODelay if you need to sleep/spin for times and/or
granularities less than 1 ms, else use IOSleep.
To clarify, if preemption is disabled prior to calling IOSleep or
IODelay, you will in fact get a "friendly spin" which calls cpu_pause
in a loop, and your thread will remain on the current cpu/core, until
the deadline expires.
The IODelay function should probably be modified to disable
preemption across the call, making it behave as-per documentation.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden