Skip to content

Instantly share code, notes, and snippets.

Created April 20, 2017 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e7d4739847ae406632e6ec5a7a4f111a to your computer and use it in GitHub Desktop.
Save anonymous/e7d4739847ae406632e6ec5a7a4f111a to your computer and use it in GitHub Desktop.
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