Re: threading question

From: Philips (philips@iph.to)
Date: Wed Jun 13 2001 - 09:17:51 EST


"J . A . Magallon" wrote:
>
> 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.
>

        BTW.
        Question was poping in my mind and finally got negative answer by my mind ;-)

        Is it possible to make somethis like:

        char a[100] = {...}
        char b[100] = {...}
        char c[100];
        char d[100];
        
        1: { // run this on first CPU
                for (int i=0; i<100; i++) c[i] = a[i] + b[i];
        };
        2: { // run this on any other CPU
                for (int i=0; i<100; i++) d[i] = a[i] * b[i];
        };
        
        ...
        // do something else...
        ...
        
        wait 1,2; // to be sure c[] and d[] are ready.

        what was popping in my mind - some prefix (like 0x66 Intel used for 32
instructions) to say this instruction should run on other CPU?
        I know - stupid idea. Too many questions will arise.
        If we will do

        PREFIX jmp far some_routing

        and this routing will run on other CPU not blocking current execution thread.
        (who will clean stack? when?.. question without answers...)

        Is there anything like this in computerworld? I heard about old computers that
have a speacial instruction set to implicit run code on given processor.
        Is it possible to emulate this behavior on PCs?


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



This archive was generated by hypermail 2b29 : Fri Jun 15 2001 - 21:00:18 EST