LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 04-22-2008, 08:31 AM   #1
Manjunath1847
Member
 
Registered: Mar 2007
Posts: 44

Rep: Reputation: 16
semaphore in linux with maxcount and time out


I am porting a Windows application to Linux. I need to set a time out for the semaphore wait operation. I did it with sem_trywait in a loop. Is there a better way?

How to set set the maximum count for a semaphore ? Anybody has a wrapper written with these functionalities implemented ?

thanks
Manju
 
Old 04-22-2008, 11:45 AM   #2
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
"man sem_wait" gives sem_timedwait which seems to do the job.
It's easy to get the current semaphore value with "sem_getvalue" and then don't "sem_post" if the value is greater than the max you need.
 
  


Reply

Tags
programming



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
Linux semaphore behaviod icarus127 Linux - General 0 10-07-2007 02:01 PM
Linux kernel module programming(Signal and semaphore) eshwar_ind Programming 1 02-16-2004 12:10 PM
how to use fork and semaphore in C/C++ in Linux? cs87668 Programming 1 06-20-2003 10:07 AM
semaphore init problem in linux marry_jeo Programming 0 02-25-2003 11:20 PM

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

All times are GMT -5. The time now is 12:53 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