lkml.org 
[lkml]   [1999]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Binding processes to selected CPUs
Avi Kivity wrote:
>
> This patch, against 2.3.18ac8, allows a process to specify which CPUs it
> may execute on. It provides functionality similar to NT's ``thread
> affinity''.
>
Oh, and the following programlet demonstrates this feature:

$ bindcpu
--> displays the cpus bound to the current process

$ bindcpu mask-in-decimal command args...
--> execs command after binding it to the processors specified in mask.

Note that cpu bindings are inherited on fork().

#include <sys/prctl.h>
#include <stdio.h>
#include <unistd.h>

int main(int ac, char** av, char** ep)
{
if (ac == 1) {
unsigned long binding = 0;
prctl(PR_GET_CPUBINDING, &binding);
printf("CPU binding: %08lX\n", binding);
} else {
unsigned long binding = atoi(av[1]);
prctl(PR_SET_CPUBINDING, binding);
execve(av[2], av+2, ep);
}
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:1.986 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site