re: msleep() with PDROP
re: msleep() with PDROP
- Subject: re: msleep() with PDROP
- From: Rick Macklem <email@hidden>
- Date: Sun, 9 Dec 2007 16:30:41 -0500 (EST)
I feel a bit silly responding to my own posting, but I think I figured it
out and thought I'd see if I got it right:
In various places in the xnu kernel I see code like the following:
#1 msleep(<event>, my_mutex, PDROP, "mysleep", 0);
lck_mtx_lock(my_mutex);
So, why do the above instead of:
#2 msleep(<event>, my_mutex, 0, "mysleep", 0);
My understanding was that msleep() would release the mutex and then
re-acquire it, if PDROP isn't specified.
Is there any fundamental difference between door #1 and door #2?
#1 - always releases/acquires the mutex, allowing other threads wanting
the mutex to get a turn
#2 - holds the mutex unless it sleeps
Does this make sense (ie. #1 is used to give other threads a chance to
lock the mutex even if the msleep() doesn't actually sleep)?
Still seems a little weird to call msleep() unless you need to sleep.
Again, thanks in advance for any info, rick
_______________________________________________
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