Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mutex = ...;
- if(fork()) {
- // parent
- file = ...;
- while(true) {
- sem_wait(mutex);
- write_to_file("this is number blah from parent", file);
- sem_post(mutex);
- }
- } else {
- file = ...;
- for(int i = 0; i < 5; i++) {
- sem_wait(mutex);
- write_to_file("This is from the child", file);
- sem_post(mutex);
- }
- sem_close(mutex);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement