How to wait for multiple threads simultaneously? - Linux

This is a discussion on How to wait for multiple threads simultaneously? - Linux ; Rainer Weikusat writes: > David Schwartz writes: >> On Feb 18, 4:08 am, Rainer Weikusat wrote: >> >>> I am using the term the way it is used in existing literature on this >>> topic and existing code, as I ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 21 to 22 of 22

Thread: How to wait for multiple threads simultaneously?

  1. Re: How to wait for multiple threads simultaneously?

    Rainer Weikusat writes:
    > David Schwartz writes:
    >> On Feb 18, 4:08 am, Rainer Weikusat wrote:
    >>
    >>> I am using the term the way it is used in existing literature on this
    >>> topic and existing code, as I have already written at least three
    >>> times, once even above. If you think that you need to dispute basic
    >>> principles of synchronization in multiprocessor operating systems and
    >>> rather have it your way than the way 'everybody else does it' (aka
    >>> 'existing code') I am not going to dispute your right 'to call a spade
    >>> a cauliflower'.
    >>>
    >>> But this does not mean that I am doing the same.

    >>
    >> You are welcome to disagree with both me and POSIX:

    >
    > As I now write for the fourth time, still in the hope that it
    > eventually reach the empty space between your ears: THIS IS NOT MY
    > OPINION.


    For sake of completeness:

    Spin Locks

    * Background

    Spin locks represent an extremely low-level synchronization
    mechanism suitable primarily for use on shared memory
    multi-processors. It is typically an atomically modified Boolean
    value that is set to one when the lock is held and to zero when
    the lock is freed.

    ,----
    | When a caller requests a spin lock that is already held, it
    | typically spins in a loop testing whether the lock has become
    | available. Such spinning wastes processor cycles so the lock
    | should only be held for short durations and not across
    | sleep/block operations. Callers should unlock spin locks before
    | calling sleep operations.
    `----

    Spin locks are available on a variety of systems. The functions
    included in IEEE Std 1003.1-2001 are an attempt to standardize
    that existing practice.

    [...]

    * Spin Locks versus Mutexes

    It has been suggested that mutexes are an adequate synchronization
    mechanism and spin locks are not necessary. Locking mechanisms
    typically must trade off the processor resources consumed while
    setting up to block the thread and the processor resources consumed by
    the thread while it is blocked. Spin locks require very little
    resources to set up the blocking of a thread. Existing practice is to
    simply loop, repeating the atomic locking operation until the lock is
    available.

    http://www.opengroup.org/onlinepubs/...ag_03_02_09_05

    SUS does not require that the spin lock interface actually provides
    'spinning locks' and 'some systems' (a quick search resulted in QNX
    and possibly [some versions of] RTEMS) map them just to mutexes.

  2. Re: How to wait for multiple threads simultaneously?

    On Feb 18, 5:11 am, Rainer Weikusat wrote:

    > As I now write for the fourth time, still in the hope that it
    > eventually reach the empty space between your ears: THIS IS NOT MY
    > OPINION.


    So would you consider it inappropriate for a POSIX spin lock
    implementation to block instead of busy waiting if it was running on a
    machine with only a single CPU? Should we avoid saying that
    pthread_spin_lock "spins" because it might not busy wait?

    DS

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2