Created
April 20, 2017 18:47
-
-
Save anonymous/e7d4739847ae406632e6ec5a7a4f111a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct sharedMemory // my shared memory structure | |
{ | |
int input; | |
int output; | |
int end; | |
int buffer[5]; | |
sem_t* semaphores[3]; // how would I get references to the 3 semaphores I semgetted at line 15? | |
}; | |
int SemaphoreSetID; | |
int main() | |
{ | |
// I omitted shared memory allocation, since it's irrelevant here | |
SemaphoreSetID = semget(IPC_PRIVATE, 3, 0600); | |
semctl(SemaphoreSetID, 0, SETVAL, 1); | |
semctl(SemaphoreSetID, 0, SETVAL, 5); | |
semctl(SemaphoreSetID, 0, SETVAL, 5); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment