|
|
|
|
|
|
| Author |
Message |
clusardi2k@aol.com *nix forums beginner
Joined: 19 Jul 2005
Posts: 40
|
Posted: Tue Jul 19, 2005 10:05 am Post subject:
Is There Something like a Semaphore with Specifiable Timeout
|
|
|
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
|
Posted: Tue Jul 19, 2005 5:11 pm Post subject:
Re: Is There Something like a Semaphore with Specifiable Timeout
|
|
|
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
|
Posted: Thu Jul 28, 2005 5:49 pm Post subject:
Re: Is There Something like a Semaphore with Specifiable Timeout
|
|
|
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
|
Posted: Fri Jul 29, 2005 5:08 am Post subject:
Re: Is There Something like a Semaphore with Specifiable Timeout
|
|
|
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 |
|
 |
|
|
The time now is Fri Jan 09, 2009 8:20 am | All times are GMT
|
|
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
|
|