![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| semaphore | raguramtgr | UNIX for Dummies Questions & Answers | 7 | 06-15-2009 09:39 AM |
| Semaphore | Jaken | Shell Programming and Scripting | 2 | 04-04-2009 05:10 PM |
| Problem with releasing semaphore lock | jacques83 | High Level Programming | 1 | 09-29-2006 05:43 PM |
| Semaphore | vjsony | UNIX for Dummies Questions & Answers | 3 | 04-07-2003 02:06 PM |
| semaphore | yls177 | UNIX for Dummies Questions & Answers | 1 | 10-08-2002 11:18 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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? |
|
|||||
|
Wrong subforum - should be moved to
High Level Programming - The UNIX Forums |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|