Reputation: 31
I am trying to use POSIX in windows and use semaphores for synchronization of C and C++ programs.Since we are talking for separate programs, is this even possible? Or semaphores are only for sync in C/C++ files of the same program?
Upvotes: 0
Views: 1163
Reputation: 1072
For synchronization between seperate processes, a semaphore needs to be used.
See the following: Semaphores
Upvotes: 0
Reputation: 73
For communication between different programs, you need to use named semaphores. In POSIX Threads, the correct method to acquire a semaphore is : sem_open Just give a name to the semaphore, and use the same name in the programs which need to communicate.
See this answer for more details on how to do it: How to share semaphores between processes using shared memory
Upvotes: 1
Reputation: 149125
Semaphores are members in Inter Process Communication tools. They can natively be used in C or C++ to synchronize different programs.
Upvotes: 0