[lkml]   [2007]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Question about setting affinity in 2.4
Hi Phy !

On Sun, Feb 18, 2007 at 06:02:17PM -0800, Phy Prabab wrote:
> Hello everyone,
> I am trying to set affinity on a program to make sure I can get the
> best use of the cache as possible and to eliminate as much noise as
> possible with running my program. I have tried unsuccessfully to set
> affinity using sched_set/getaffinity and the CPU_SET macros. In
> particular, I can not seem to get the process to use affinity I
> specify as in:
> int main () {
> cpu_set_t mask;
> cpu_set_t setmask;
> long long x;
> double foo;
> printf("Mask set to %08lx\n", sched_getaffinity(0, &mask));
> CPU_SET(1, &mask);
> if (sched_setaffinity(0, &mask) == -1) {
> printf("error setting affinity.");
> }
> printf("Mask is reset to %08lx\n", sched_getaffinity(0, &mask));
> // do some long lasting calculations ....
> return;
> }
> No mater what I do, the process is never bond to the processor in
> question as exposed by this little appy and by cat /proc/<pid>/cpu.
> Is this just impossible to do?
> Ah, the kernel I am using is RH 2.4.21-37.ELsmp.

I don't know for RH kernel, but the affinity syscalls are not in 2.4
mainline. You can apply the patch without much hassle if you want. It's
in Robert Love's directory :

I believe you'll have to use an -ac patch for RHEL.

> TIA!
> Phy


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-02-19 05:43    [W:0.087 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site