I'm using synchronization KPI in my macOS kernel extension to verify that one function is fully performed before the other function starts (both functions are performed in different threads of course).
These are the synchronization methods :
msleep(void *channel,lck_mtx_t *mtx,int priority,const char *wmesg, struct timespec *timeout);
wakeup(void *channel);
So channel
is a pointer to boolean value that represent first function was fully performed.
Here's my implementation in the first function:
OSIncrementAtomic(channel);
wakeup(channel);
And on the other function I wait for channel
to be set:
msleep(channel, NULL, 0, "", ts);
However, in case the first function terminated before the second one (which is the common case), I shell wait for the timeout in ts
for vein.
My question is whether there's a way to skip the msleep
in case the wakeup
already occurred ?
thanks,