LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-13-2005, 08:54 PM   #1
ringerxyz
LQ Newbie
 
Registered: Nov 2004
Location: China
Distribution: red-flag
Posts: 16

Rep: Reputation: 0
problems with semget


Hi everyone,
I have a question about the first parameter of the semget :key_t key,
if two process use the same key value,they will get the same semaphore ,and now if a third process happend to be have the same kye value,then it will use the same semaphore with the first and second process,is this right?
if this is right ,then how to guarantee that a semaphore is only used by the first and the second process?
 
Old 02-13-2005, 09:21 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Check out the semctl command. You can use that command to set the permissions for the semephore and all that good stuff.
 
Old 02-14-2005, 06:30 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Re: problems with semget

Quote:
Originally posted by ringerxyz
if this is right ,then how to guarantee that a semaphore is only used by the first and the second process?
Yes, this is right. And it can be a problem when another process uses the same IPC-key, while it wasn't meant to connect to that same IPC-resource. Proper permissions can prevent that of course, but the third process will fail getting a semaphore in that case.

The library function ftok() is there to improve chances getting a IPC-key that is unique, but still it will not guarantee it.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
a strange question about "semget" iclinux Other *NIX 2 06-15-2005 11:58 PM
Ethernet Adsl Modem Driver Problems And Install Problems... akhilnair Linux - Hardware 12 11-28-2004 08:19 AM
cisco 350 wireless problems and suse x-server problems incognito9 Linux - Wireless Networking 5 10-14-2004 07:53 AM
Problems, problems, problems. Lets start with the soundcard Kre8ive Linux - Newbie 5 08-07-2003 01:20 AM
Problems, problems, problems. Lets start with the ES 1868 AudioDrive Kre8ive Linux - Newbie 1 08-06-2003 07:04 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration