Jefferson Coelho
|
Issues with pthread_cancel()
|
Jefferson Coelho
03/02/2009 4:10 PM
post23275
|
Issues with pthread_cancel()
In my application, the main (process) thread creates a detached thread by invoking pthread_create(), storing the thread
ID in (say) pub_thread. The created thread runs run_publish_thread(), a function that never returns.
Within run_publish_thread(), another detached thread is also created; the thread ID is stored in (say) timer_thread, and
it runs timeout_thread(). Timeout_thread() basically starts a nanosleep() as fast as possible. So far so good.
The issue starts when the main thread calls pthread_cancel(timer_thread), as timer_thread is still executing the
nanosleep(). The side effect of calling pthread_cancel() is that *both* pub_thread and timer_thread are being canceled.
I am running QNX 6.3.2 in a x86 target. Any suggestions on run to proceed? Is this expected behavior?
Many thanks for any help you may offer,
- Jefferson
|
|
|