fcntl() for thread or process synchronization?
问题 Is it possible to use fcntl() system call on a file to achieve thread/process synchronization (instead of semaphoress)? 回答1: Yes. Unix fcntl locks (and filesystem resources in general) are system-wide, so any two threads of execution (be they separate processes or not) can use them. Whether that's a good idea or not is context-dependent. 回答2: That's one way of synchronizing between processes, but if you don't want to use semaphores, you could use process shared mutexes, such as mutexes and