Is There Something like a Semaphore with Specifiable Timeout - SGI

This is a discussion on Is There Something like a Semaphore with Specifiable Timeout - SGI ; 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, ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Is There Something like a Semaphore with Specifiable Timeout

  1. 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


  2. 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/ --

  3. Re: Is There Something like a Semaphore with Specifiable Timeout

    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 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

  4. Re: Is There Something like a Semaphore with Specifiable Timeout

    In article <20050728144632.W5118@chenjesu.americas.sgi.com>,
    Brent Casavant 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/ --

+ Reply to Thread