Chinaunix

标题: how protect a context in a thread without mutex and semophore [打印本页]

作者: zhutroy    时间: 2011-04-18 00:25
标题: how protect a context in a thread without mutex and semophore
There are two threads
thread1 always call ioctl one time every second.
thread2 always call two steps ioctl  one time every second.

thread2 require two step must not be interrupted by thread1's ioctl
The operations as the following is not permitted.
ioctl //thread2
ioctl //thread1 interrupted
ioctl //thread2

I want to use pthread_mutex, semaphore, cond_wait .... but because thread1 is a lib.
and it can't not be changed.
So how can I protect two steps ioctl, guarantee it will not be interrupted by thread1?

Thanks very much.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2