[Assorted-commits] SF.net SVN: assorted: [410] cpp-commons/trunk/src/commons/threads.h
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-14 00:10:05
|
Revision: 410 http://assorted.svn.sourceforge.net/assorted/?rev=410&view=rev Author: yangzhang Date: 2008-02-13 16:10:10 -0800 (Wed, 13 Feb 2008) Log Message: ----------- added pin_thread Modified Paths: -------------- cpp-commons/trunk/src/commons/threads.h Modified: cpp-commons/trunk/src/commons/threads.h =================================================================== --- cpp-commons/trunk/src/commons/threads.h 2008-02-13 18:03:22 UTC (rev 409) +++ cpp-commons/trunk/src/commons/threads.h 2008-02-14 00:10:10 UTC (rev 410) @@ -22,6 +22,19 @@ } /** + * Pin the thread to the given CPU number (as defined for sched_setaffinity). + */ + void + pin_thread(int cpu) + { + pid_t pid = gettid(); + cpu_set_t cs; + CPU_ZERO(&cs); + CPU_SET(cpu, &cs); + sched_setaffinity(pid, sizeof(cs), &cs); + } + + /** * Wait for all the given threads to join, discarding their return values. */ inline void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |