Re: processor affinity and GThread



Hi Rick,

> Netperf4 is a multi-threaded network performance benchmark.  There is a 
> main thread in the netperf4 netserver that creates "test threads" which 
> run test-specific code that we really don't want to need/have any 
> platform-specific knowledge.
>
> One of those things is CPU binding - binding the test thread to a 
> specific CPU, CPU set or locality domain.  To "protect" the test thread 
> and its code from that platform-specific knowledge the main netserver 
> thread makes processor affinity calls to set the processor affinity of 
> the newly created test thread.
> 
> This is fine with pthreads under HP-UX and Linux - the main netserver 
> thread can go ahead and make the affinity call(s) and affect the 
> affinity of the test thread.  The affinity calls take platform native 
> thread id's and so the pthread_t is just passed-in.  The test thread 
> remains fat dumb and happy doing its test-specific thing.
> 
> Now, with the addition of the gthread abstraction to port netperf4 to 
> Windows, and ultimately I suppose use of gthreads on other platforms 
> (particularly when netperf4 goes gui with gtk+) I don't have the native 
> thread ID at my fingertips.
> 
> I know it is evil and a "don't do that!" sort of thing, but barring 
> plans to add affinity calls to gthread 

I do not think, this problem is common enough to warrant a GLib
functions.

> (and even then for the interim), 
> it seems I need to know how to peel-back the opaque veneer of the 
> GThread abstration to retrieve the native thread id contained therein.

On one hand you could simply cast the GThread to a pthread_t, but I
would strongly advise against that. What do you think of introducing a
callback, which the thread will call once created. This could do all it
wants with the currently running thread by means of
pthread_self/GetCurrentThread/whatever. That would be simple, working
and clean.

Bye,
Sebastian
-- 
Sebastian Wilhelmi                 |            här ovanför alla molnen
mailto:seppi seppi de              |      är himlen så förunderligt blå
http://seppi.de




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]