The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-28-2008
Dreams in Blue Dreams in Blue is offline
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?
  #2 (permalink)  
Old 05-29-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Wrong subforum - should be moved to
High Level Programming - The UNIX Forums
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0