public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: linux-kernel@vger.kernel.org
Cc: torvalds@transmeta.com, mingo@elte.hu
Subject: Re: [PATCH] 2.5: (better) syscalls for setting task affinity
Date: 27 Feb 2002 19:13:47 -0500	[thread overview]
Message-ID: <1014855228.1107.244.camel@phantasy> (raw)
In-Reply-To: <1014853522.1109.234.camel@phantasy>
In-Reply-To: <1014853522.1109.234.camel@phantasy>

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

On Wed, 2002-02-27 at 18:45, Robert Love wrote:

> The attached patch implements a syscall interface for setting and
> retrieving a task's CPU affinity (task->cpus_allowed):

I should posted a test program to demonstrate the syscalls - find such
an attachment below.  It demonstrates using sched_get_affinity to find
the length of the cpu bitmask and then get and set a new value.

`pid_t p' is the process in question.
`unsigned long new_mask' is the new bitmask.

	Robert Love





[-- Attachment #2: affinity.c --]
[-- Type: text/x-c, Size: 1075 bytes --]

/*
 * Example of sched_set_affinity and sched_get_affinity
 * 	Robert Love, 20020227
 */

#include <stdio.h>
#include <stdlib.h>
#include <linux/unistd.h>
#include <unistd.h>

#define __NR_sched_set_affinity 239
#define __NR_sched_get_affinity 240

_syscall3 (int, sched_set_affinity, pid_t, pid, unsigned int, len, unsigned long *, new_mask_ptr)
_syscall3 (int, sched_get_affinity, pid_t, pid, unsigned int *, user_len_ptr, unsigned long *, user_mask_ptr)

int main(int argc, char * argv[])
{
	unsigned long new_mask = 2;
	unsigned int len;
	unsigned long cur_mask;
	pid_t p = getpid();
	int ret;

	ret = sched_get_affinity(p, &len, NULL);
	printf(" len = %u\n", len);

	ret = sched_get_affinity(p, &len, &cur_mask);
	printf(" sched_get_affinity = %d, cur_mask = %ld\n", ret, cur_mask);

	ret = sched_set_affinity(p, len, &new_mask);
	printf(" sched_set_affinity = %d, new_mask = %ld\n", ret, new_mask);

	ret = sched_get_affinity(p, &len, &cur_mask);
	printf(" sched_get_affinity = %d, cur_mask = %ld\n", ret, cur_mask);

	return 0;
}

  reply	other threads:[~2002-02-28  0:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-27 23:45 [PATCH] 2.5: (better) syscalls for setting task affinity Robert Love
2002-02-28  0:13 ` Robert Love [this message]
2002-02-28  0:20 ` Mike Kravetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1014855228.1107.244.camel@phantasy \
    --to=rml@tech9.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox