Boost logo

Threads-Devel :

Subject: Re: [Threads-devel] [thread] How to change a thread's scheduling values?
From: Anthony Williams (anthony_at_[hidden])
Date: 2010-07-09 18:04:28

On 09/07/10 16:01, John Rocha wrote:
> I know how to do this using pthread_xxxxx() calls. However, we are being
> encouraged to use the boost library for our thread new thread
> development. I don't see any methods that would allows one to change the
> threads scheduling.

No, this is not part of the boost.thread API.

> I revisited my pthread functions, and assuming boost is using pthreads
> under the covers I could conceivably get the current running thread id
> using pthread_self(). Then I can use the returned thread_t (thread id)
> for getting and setting the threads scheduling parameters.

Yes, that seems sensible.

> How does one go about changing the scheduling and priority of their
> threads when they use the boost::thread library?

Use the native thread library (pthreads in this case). You can either
use pthread_self() to get a handle to the current thread, or call
native_handle() on the boost::thread object to get the handle of another


Author of C++ Concurrency in Action
just::thread C++0x thread library   
Just Software Solutions Ltd
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Threads-Devel list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at