![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Semaphore | Jaken | Shell Programming and Scripting | 1 | 05-06-2007 09:17 PM |
| Problem with releasing semaphore lock | jacques83 | High Level Programming | 1 | 09-29-2006 02:43 PM |
| semaphore | raguramtgr | UNIX for Dummies Questions & Answers | 3 | 07-27-2004 01:18 AM |
| Semaphore | vjsony | UNIX for Dummies Questions & Answers | 3 | 04-07-2003 11:06 AM |
| semaphore | yls177 | UNIX for Dummies Questions & Answers | 1 | 10-08-2002 08:18 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Semaphore problem....
I'm having an issue implementing my semaphores....
The following is how I'm setting up the semaphore. First: I get the semkey (which I've wrapped in an IF statement using perror() but in an attempt to keep the code clutter free I've removed it here) semkey = ftok("./request", 'S' ) Second: I get the semid (again wrapped in an IF statement ) semid = semget ( semkey, 1, 0666 | IPC_CREAT ) Third: I initialise semaphore #0 to 1 arg.val = 1 semctl ( semid, 0, SETVAL, arg ) The following is where the problem is occuring (it seems), this is where I'm actually using the semaphore - semop() - to allow access to a shared memory segment (critical code) while ( allocate.sem_op == -1 ) { //printf ( "waiting for semaphore to release\n" ); } allocate.sem_op = -1; if ( semop( semid, &allocate, 1 ) == -1 ) { perror ("Semaphore error3: semop()"); exit(1); } //CRITICAL CODE HERE allocate.sem_op = 1; if ( semop( semid, &allocate, 1 ) == -1 ) { perror ("Semaphore error4: semop()"); exit(1); } I've left a fair bit of the code out, such as struct sembuf and union semun stuff, but that appears to be working properly..... The error I'm getting is this: Semaphore error4: semop(): File too large Where should I look or what is it that I'm doing wrong? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Wrong subforum - should be moved to
High Level Programming - The UNIX Forums |
|||
| Google The UNIX and Linux Forums |