Linux "complete()" and "wait_for_completion_t

Hi Folks,

I’m porting a Linux driver to QNX. The driver uses “complete(struct completion *x)” and “wait_for_completion_timeout(struct completion *x, unsigned long timeout)” kernel call in Linux. What is the best way to implement these functions in QNX? Can I just use semaphore to implement block waiting?

Thanks!
Yicheng

You shouldn’t use semaphores (as they cannot convey priority). You should use a mutex/condvar.

You probably want pthread_sleepon_* (this is a wrapper for a mutex and condvar).

Is it “async safe” to use “mutex/condvar” or “pthread_sleepon_*”? Can I call “mutex_lock” in a signal handler?

Thanks!
Yicheng

If it wouldn’t be “async safe” they wouldn’t have much use would they ;-)

At the bottom of the page of the documentation of each QNX/C functions there is a table that shows how safe the function is. Check it out for pthread_mutex_lock.