LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-19-2007, 11:26 PM   #1
ksrinivas
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Rep: Reputation: 0
how to get semphore count


Hello Everybody,

I am using "sem_getcount" to get the semaphore count. But the gcc compiler is not recognizing this. I am using Linux version 2.6.9-22.EL gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)).

Can anyone please tell me how to get the semaphore count??

Thanks in advance,

Regards
Srinivas
 
Old 01-20-2007, 12:09 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
I'm not sure what exactly you are looking for but you can look at "sysctl kernel.sem". This page has some info on interpreting the parameters. See also the sysctl(2) man page for doing it via syscalls within a C program.
 
Old 01-20-2007, 01:01 AM   #3
ksrinivas
LQ Newbie
 
Registered: Sep 2006
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks for the reply.
Let me tell you What i am doing. In my C code, inside a blocking read call i waiting for the semaphore based on its count. So i will wait until some one releases the semaphore and the same i am checking through the sem_getcount().
So the problem that i am facing is "sem_getcount" not compilable. Is there any other way to get the semaphore count ???

Regards
Srinivas
 
Old 01-20-2007, 01:36 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
OK, so you don't actually need to know the number of semaphores available on your system, you just need to know the value of a particular one. I totally misread you, which is why it's good to be specific when asking a question so people have some idea what you want.

In any case, I have not written semaphore code in a looong time but I think you can do what you want using semctl with the GETVAL cmd argument. Please see "man semctl" for more details. Note that this is if you're using the System V style semaphore API. If you're using POSIX semaphores the correct function is sem_getvalue (the description is in the man page for sem_init).based on the fact you were looking for sem_getcount (note the underscore), I'm guessing you're using POSIX semaphores and so sem_getvalue is the function you seek.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Count of two columns vimal480 Programming 1 04-16-2005 02:25 AM
Bono can't count ghight General 7 10-26-2004 01:50 PM
how to count files disorderly Linux - Newbie 5 08-24-2004 01:36 PM
Should posts in general count on your post count? Joey.Dale General 16 01-27-2004 01:31 AM
dd: bs=2X , count=?X adam_boz Linux - General 3 10-27-2002 07:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:11 AM.

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