lkml.org 
[lkml]   [2001]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: threading question

    On 20010613 Kurt Garloff wrote:
    >
    > What I do in my numerics code to avoid this problem, is to create all the
    > threads (as many as there are CPUs) on program startup and have then wait
    > (block) for a condition. As soon as there's something to to, variables for
    > the thread are setup (protected by a mutex) and the thread gets signalled
    > (cond_signal).
    > If you're interested in the code, tell me.
    >

    I use the reverse approach. you feed work to the threads, I create the threads
    and let them ask for work to a master until it says 'done'. When the
    master is queried for work, it locks a mutex, decide the next work for
    that thread, and unlocks it. I think it gives the lesser contention and
    is simpler to manage.

    --
    J.A. Magallon # Let the source be with you...
    mailto:jamagallon@able.es
    Linux Mandrake release 8.1 (Cooker) for i586
    Linux werewolf 2.4.5-ac13 #1 SMP Sun Jun 10 21:42:28 CEST 2001 i686
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 12:55    [W:0.023 / U:30.124 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site