niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » SGI/IRIX
Is There Something like a Semaphore with Specifiable Timeout
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
clusardi2k@aol.com
*nix forums beginner


Joined: 19 Jul 2005
Posts: 40

PostPosted: Tue Jul 19, 2005 10:05 am    Post subject: Is There Something like a Semaphore with Specifiable Timeout Reply with quote

Hello,

I am looking for instructions that do what a mutual exclusive
semaphore does but with some specifiable timeout for SGI and Red
Hat Linux. (I.E.: A Semaphore with a count of 1 but with a timeout)


In other words, I want to know how to guard a critical piece of
code, but I don't want to be forced to wait a long time in a
queue. In other words, I have processes that could go on living
without entering the critical section of code.

Thank you,
Christopher Lusardi
Back to top
Tony 'Nicoya' Mantler
*nix forums Guru Wannabe


Joined: 02 Jul 2005
Posts: 139

PostPosted: Tue Jul 19, 2005 5:11 pm    Post subject: Re: Is There Something like a Semaphore with Specifiable Timeout Reply with quote

In article <1121774738.656254.234040@g49g2000cwa.googlegroups.com>,
clusardi2k@aol.com wrote:

: Hello,
:
: I am looking for instructions that do what a mutual exclusive
: semaphore does but with some specifiable timeout for SGI and Red
: Hat Linux. (I.E.: A Semaphore with a count of 1 but with a timeout)
:
:
: In other words, I want to know how to guard a critical piece of
: code, but I don't want to be forced to wait a long time in a
: queue. In other words, I have processes that could go on living
: without entering the critical section of code.

The pthread condvar functions support a timeout while waiting (through
pthread_cond_timedwait()), but it would probably be a bit silly to use a condvar
as a mutex, depending on your application.

If your application would perform adequately with no waiting at all, you can use
trylock variants of your usual locking calls (like pthread_mutex_trylock()).

I would suggest against using alarm() to time out locking calls. Going down that
route will make a *really* big mess of things.

It's hard to say what the right solution for you is without knowing more about
the nature of your code.


Cheers - Tony 'Nicoya' Mantler :)

--
Tony 'Nicoya' Mantler -- Master of Code-fu -- nicoya@ubb.ca
-- http://nicoya.feline.pp.se/ -- http://www.ubb.ca/ --
Back to top
Brent Casavant
*nix forums beginner


Joined: 28 Jul 2005
Posts: 2

PostPosted: Thu Jul 28, 2005 5:49 pm    Post subject: Re: Is There Something like a Semaphore with Specifiable Timeout Reply with quote

On Tue, 19 Jul 2005 clusardi2k@aol.com wrote:

Quote:
I am looking for instructions that do what a mutual exclusive
semaphore does but with some specifiable timeout for SGI and Red
Hat Linux. (I.E.: A Semaphore with a count of 1 but with a timeout)


In other words, I want to know how to guard a critical piece of
code, but I don't want to be forced to wait a long time in a
queue. In other words, I have processes that could go on living
without entering the critical section of code.

Assuming you're using IRIX, usopenpollsema(3P) should steer you
in the right direction.

Linux doesn't have an equivalent. futex's have something that
looks like it should be useful (FUTEX_FD), however it's really
not, and discussions on the Linux kernel mailing list have largely
concluded that it's broken as designed.

Sorry about the lag. Better late than never though, right?

Brent

--
Brent Casavant Dance like everybody should be watching.
www.angeltread.org
KD5EMB, EN34lv
Back to top
Tony 'Nicoya' Mantler
*nix forums Guru Wannabe


Joined: 02 Jul 2005
Posts: 139

PostPosted: Fri Jul 29, 2005 5:08 am    Post subject: Re: Is There Something like a Semaphore with Specifiable Timeout Reply with quote

In article <20050728144632.W5118@chenjesu.americas.sgi.com>,
Brent Casavant <bcasavan@angeltread.org> wrote:

: On Tue, 19 Jul 2005 clusardi2k@aol.com wrote:
:
: > I am looking for instructions that do what a mutual exclusive
: > semaphore does but with some specifiable timeout for SGI and Red
: > Hat Linux. (I.E.: A Semaphore with a count of 1 but with a timeout)
: >
: >
: > In other words, I want to know how to guard a critical piece of
: > code, but I don't want to be forced to wait a long time in a
: > queue. In other words, I have processes that could go on living
: > without entering the critical section of code.
:
: Assuming you're using IRIX, usopenpollsema(3P) should steer you
: in the right direction.

Linux has semtimedop(), which I don't think is available in IRIX. I neglected to
mention it in my previous post.

There doesn't seem to be much love for cross-platform compatibility in this area.


Cheers - Tony 'Nicoya' Mantler :)

--
Tony 'Nicoya' Mantler -- Master of Code-fu -- nicoya@ubb.ca
-- http://nicoya.feline.pp.se/ -- http://www.ubb.ca/ --
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 8:20 am | All times are GMT
navigation Forum index » *nix » SGI/IRIX
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts random timeout / delivery temporarily suspended unarcher Postfix 0 Fri Jun 13, 2008 12:33 pm
No new posts CGI-Timeout causing "internal server error"???? Carl Lafferty Perl 6 Thu Jul 20, 2006 8:58 pm
No new posts Timeout in HTML Sonnich PHP 5 Wed Jul 19, 2006 3:54 pm
No new posts DECnet session timeout Brian VMS 3 Wed Jul 19, 2006 1:01 am
No new posts timeout - ? & kernel parameters tomcaml@yahoo.com AIX 2 Tue Jul 18, 2006 9:03 pm

Credit Card Debt Consolidation | Web Advertising | Great deals at Champion Achiever | MPAA | Debt Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2403s ][ Queries: 16 (0.1509s) ][ GZIP on - Debug on ]