The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-28-2008
Registered User
 

Join Date: May 2008
Posts: 3
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?
Reply With Quote
Forum Sponsor
  #2  
Old 05-28-2008
Moderator
 

Join Date: Sep 2007
Location: Germany
Posts: 1,031
Wrong subforum - should be moved to
High Level Programming - The UNIX Forums
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 02:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0