Subj : Re: share a exclusive resource between the threads inside the different processes To : comp.programming.threads From : Hank Date : Thu Mar 24 2005 04:31 pm First...thanks very much for your help.. The resource is actually a character device, and the application(s) can communicate with that device with the ioctl(...) function after the open(...) function was called. In the normal circumstance, if a thread issues a ioctl(...) to get some information from the device and wait for reply, another thread(may be in the different process or the same one, but I emphasize it in the different process) may not be allowed to interrupt previously one. Pseudo code: int main(...) { int hDev = open("/dev/cdev", O_RDWR); .... if(hDev == -1) { // do some error handling } start_thread(ThreadFunc); } /* The following was the code inside the thread function, the codes between Lock() and Unlock() was not allowed to interrupt by another thread, even the thread was in the different process, actually this is what I want. */ void *ThreadFunc(void *params) { struct BUFFER buffer; int status; Lock(); status = ioctl(hDev , IOCTL_WRITE_BUFFER, (unsigned long)&buffer) == -1) if(status != SUCCESS) { // do some error handling } // may wait for a while status = ioctl(hDev , IOCTL_READ_BUFFER, (unsigned long)&buffer) == -1) if(status != SUCCESS) { // do some error handling } Unlock(); ...... ...... } So far as I know the mutex PTHREAD_PROCESS_SHARED attribute was not implemented, right? so how can I share the POSIX mutex object between the processes? shmop(...)?, mmap(..)? or .... It good for me if the process dies, the lock is released. ^_^ Platform: Redhat 9.0 with default packages on X86 Best Regards., .