mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Arun Srinivas <getarunsri@hotmail.com>
Cc: nickpiggin@yahoo.com.au, LKML <linux-kernel@vger.kernel.org>
Subject: Re: sched_setscheduler() and usage issues ....please help
Date: Mon, 28 Mar 2005 23:40:15 -0500	[thread overview]
Message-ID: <1112071215.3691.27.camel@localhost.localdomain> (raw)
In-Reply-To: <BAY10-F472EE1F6A6F80FEA2F5568D9450@phx.gbl>

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

On Tue, 2005-03-29 at 08:58 +0530, Arun Srinivas wrote:
> I am trying to set the SCHED_FIFO  policy for my process.I am using 
> sched_setscheduler() function to do this.

Attached is a little program that I use to set the priority of tasks.

-- Steve

[-- Attachment #2: setscheduler.c --]
[-- Type: text/x-csrc, Size: 1822 bytes --]

/* Copyright (C) 2004 Kihon Technologies Inc.

   This utilities is free software, you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   These utilities are distributed in the hope that they will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */
/*
 * Author: Steven Rostedt
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <strutils.h>
#include <errno.h>

void usage (char **argv)
{
	char *arg = argv[0];
	char *p = arg + strlen(arg);
	while (p >= arg && *p != '/') p--;
	p++;
	fprintf(stderr,"usage: %s pid policy priority\n"
			"\n\twhere policy is SCHED_RR, SCHED_FIFO or SCHED_OTHER\n"
			"\n", p);
	exit(-1);
}

int main (int argc, char **argv)
{
	pid_t pid;
	int policy;
	struct sched_param p;
	char *strpolicy;
	
	if (argc != 4)
		usage(argv);

	strpolicy = argv[2];
	pid = atoi(argv[1]);
	p.sched_priority = atoi(argv[3]);

	if (strcmp(strpolicy,"SCHED_RR")==0) {
		policy = SCHED_RR;
	} else if (strcmp(strpolicy,"SCHED_FIFO") == 0) {
		policy = SCHED_FIFO;
	} else if (strcmp(strpolicy,"SCHED_OTHER") == 0) {
		policy = SCHED_OTHER;
	} else {
		fprintf(stderr,"\nunknown policy %s",strpolicy);
		usage(argv);
	}

	if (sched_setscheduler(pid,policy,&p)) {
		perror("sched_setscheduler");
		exit(errno);
	}
	exit(0);
}

  reply	other threads:[~2005-03-29  4:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-22 22:09 help needed pls. scheduler(kernel 2.6) + hyperthreaded related questions? Arun Srinivas
2005-03-22 23:16 ` Nick Piggin
2005-03-23  6:07   ` Arun Srinivas
2005-03-23  7:37     ` Nick Piggin
2005-03-23  9:47       ` Arun Srinivas
2005-03-24  0:17         ` Nick Piggin
2005-03-29  3:28       ` sched_setscheduler() and usage issues ....please help Arun Srinivas
2005-03-29  4:40         ` Steven Rostedt [this message]
2005-03-29  4:51           ` Lee Revell
2005-03-29  6:03             ` Jan Engelhardt
2005-03-29 11:35               ` Steven Rostedt
2005-03-29 11:38                 ` Jan Engelhardt
2005-03-29 11:43               ` Arjan van de Ven
2005-03-29 11:46                 ` Jan Engelhardt
2005-03-23  7:07   ` help needed pls. scheduler(kernel 2.6) + hyperthreaded related questions? Jan Engelhardt
2005-03-30 18:09 sched_setscheduler() and usage issues ....please help Arun Srinivas

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=1112071215.3691.27.camel@localhost.localdomain \
    --to=rostedt@goodmis.org \
    --cc=getarunsri@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    /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

Powered by JetHome