Re: processor affinity and GThread



Sebastian Wilhelmi wrote:
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.

Understandable. The different styles of affinity vary - HP-UX has individual CPU, Processor Set and Locality Domain. Linux seems to have individual CPU. Individual CPU is probably the common thread there, but until some other folks start asking for it I understand how it would be low interest.

How about a g_native_thread_id() call?-)

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

From what little I could decipher from the .h files I didn't even know I could do that - is it the case that the native thread "thingie" :) is the first item in the GThread?

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.

Assuming I didn't misinterpret "callback" I don't think a callback "works" here - the test code has to know to make the call. I really don't want to involve the test code because I want to try to maintain the separation of harness from test code - even as I somewhat hypocritcially want to then crack the veneer of the GTread abstraction :) but for a good cause :)

I suppose what might work, but what I really wanted to avoid, is launching the test thread with a harness function that does the native affinity thing via pthread_self et al, and then calls into the test code.

The one problem there is it seems to preclude changing the affinity later, which is something I could do when the main netserver thread was making the affinity calls.

rick jones




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