I use KPI synchronization in my macOS kernel extension to make sure that one function is fully executed before the other function runs (both functions are executed 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
- this is a pointer to a logical value representing the first function, fully executed.
Here is my implementation in the first function:
OSIncrementAtomic(channel);
wakeup(channel);
And for another function, I'm waiting for it to be installed channel
:
msleep(channel, NULL, 0, "", ts);
However, in the event that the first function is completed before the second (which is the usual case), I will wait for the shell to time out ts
for the vein.
My question is: is there a way to skip msleep
in case it wakeup
has already happened?
thank,