Almost all codes and tutorials that I read on the Internet include using mutexes and semaphores to synchronize between threads. Can they be used to synchronize between processes?
I would like to write code that looks like this:
void compute_and_print() {
}
void main() {
int pid = fork();
if ( pid == 0 ) {
compute_and_print();
}
else {
compute_and_print();
}
}
- Can someone point me to similar code that does this?
- I understand that different processes have different address spaces, but I think that if the above were different address spaces, would the mutex refer to the same kernel object?
user277465
source
share