[thread] thread pining (processor affinity)

Hello Anthony, are you interessted in a function boost::this_thread::pin_to_processor( int)? I can provide code for Windows, LINUX, HP/UX , Solaris, IRIX, AIX (xBSD seams not to offer this functionality - FreeBSD 7.1 will add processor affinity). best regards, Oliver

k-oli@gmx.de wrote:
Hello Anthony, are you interessted in a function boost::this_thread::pin_to_processor( int)?
Why not "set_affinity(<some type> processor_mask)"? It's more general and uses well-established terminology. Also, while you're at it, something like this would be valuable to be able to specify when creating a thread as well. / Johan

k-oli@gmx.de wrote:
Hello Anthony, are you interessted in a function boost::this_thread::pin_to_processor( int)?
Why not "set_affinity(<some type> processor_mask)"? It's more general and uses well-established terminology.
Most systems provide separate system calls for bind to one processor and set processor masks. So it is reasonable to provide additional functionality for setting the processor masks (not supported by many systems).
Also, while you're at it, something like this would be valuable to be able to specify when creating a thread as well.
Do this only in the ctor is not generic - I saw a lot of code which binds the thread to one processor for some special computations and after finishing unbinding the thread. Oliver -- "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail

Oliver Kowalke wrote:
k-oli@gmx.de wrote:
Hello Anthony, are you interessted in a function boost::this_thread::pin_to_processor( int)?
Why not "set_affinity(<some type> processor_mask)"? It's more general and uses well-established terminology.
Most systems provide separate system calls for bind to one processor and set processor masks. So it is reasonable to provide additional functionality for setting the processor masks (not supported by many systems).
Binding to a single processor is only a specialization of the general case, commonly supported or not.
Also, while you're at it, something like this would be valuable to be able to specify when creating a thread as well.
Do this only in the ctor is not generic - I saw a lot of code which binds the thread to one processor for some special computations and after finishing unbinding the thread.
I didn't say this should only be supported during thread creation, I wrote "... as well". For the case when you actually want a thread to run under a certain processor all the time, you're possibly wasting CPU cycles when starting the thread on an arbitrary processor, only to move the thread to a specific processor immediately after that. Coming to think of it, using the term "processor" is perhaps confusing as I guess most people relate the word to a physical CPU. Maybe "execution unit" or similar would be more generic. / Johan
participants (3)
-
Johan Nilsson
-
k-oli@gmx.de
-
Oliver Kowalke