The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How many semaphores? Watto86 UNIX for Advanced & Expert Users 8 11-08-2007 01:32 AM
semaphores using up and down ddx08 High Level Programming 7 04-03-2007 11:38 PM
semaphores kekanap Shell Programming and Scripting 1 03-27-2007 06:56 AM
Semaphores with key of 0 doeboy UNIX for Advanced & Expert Users 0 10-28-2004 04:41 PM
Semaphores joseph_shibu High Level Programming 1 11-01-2001 01:01 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-28-2006
qntmteleporter qntmteleporter is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 4
semaphores

Hi there,

Could someone please confirm which POSIX semaphore routines should be used for a multiprocess (and not multithreaded) environment?

sys/sem.h definitely works. but the routines, semget, semctl, semop are pretty unwieldy. So, I am looking for an easier way out.

From the man pages it also appears that routines in semaphore.h should work for multiprocesses.

#include <semaphore.h>
int sem_init(sem_t *sem, int pshared, unsigned int value);

The man pages say:
"If the pshared argument has a non-zero value, then the semaphore is shared between processes; in this case, any process that can access the semaphore sem can use sem for performing sem_wait(), sem_trywait(), sem_post(), and sem_destroy() operations."


However, the I am not able to achieve mutual exclusion with this. There are no compilation or runtime errors. The danm thing just doesn't work. Could somebody take a guess what I might be doing wrong?

regards,
Quantum Teleporter
 

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 10:13 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