Thread View: comp.unix.programmer
2 messages
2 total messages
Started by Bart Trojanowski
Fri, 03 Jul 1998 00:00
Linux semaphores. (semget & semop)
Author: Bart Trojanowski
Date: Fri, 03 Jul 1998 00:00
Date: Fri, 03 Jul 1998 00:00
38 lines
1526 bytes
1526 bytes
Hello, I have run into a problem with semaphores. The task that I am
building cannot be thread based so I need to create a system semaphore for
synchronization.
I tried this...
----
struct sembuf sem_wait = { 0, -1, 0 }; // also tried { 0, -1, IPC_NOWAIT
};
...
if( (waitLock = semget( key, 1, IPC_CREAT ) ) == -1)
perror("semget problem:");
...
// setup alarm handler
// setup timer here
...
if( semop( waitLock, &sem_wait, 1 ) == -1 )
perror("semop problem:");
----
where key is either IPC_PRIVATE or 0x1FF (9 bits of 1's).
Both give me an error on semop of "Permission denied". I noticed that this
runs under root, so I have concluded that I have my permissions set
incorrectly. How do I set them properly?
Well I should say that it didn't give me an error, not that it worked under
root. Another problem I have now is that the alarm handler does not get
called when I block on the sema. It would seem that the alarm is disabled.
Is that so?
thank you.
Re: Linux semaphores. (semget & semop)
Author: Lance DeHerrera
Date: Thu, 09 Jul 1998 00:00
Date: Thu, 09 Jul 1998 00:00
8 lines
793 bytes
793 bytes
After compiling the program under linux try this: 1. chmod a+x program name after this is complete Ls the directory and mv the a.out file to the program name. hope this helps!!!!!!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads