All of lore.kernel.org
 help / color / mirror / Atom feed
From: george anzinger <george@mvista.com>
To: Nicolas Bonnefon <nicolas.bonnefon@fr.thalesgroup.com>
Cc: "Eldor R�dseth" <Eldor.Rodseth@eto.ericsson.se>,
	"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Subject: Re: SCHED_FIFO and SCHED_RR in 2.4.7-10custom kernel
Date: Fri, 26 Apr 2002 09:25:08 -0700	[thread overview]
Message-ID: <3CC97F64.1D9575F9@mvista.com> (raw)
In-Reply-To: <F9CC1B4C20A0D411A99E00508BDFA6A203D8AB00@enoasnt101.eto.ericsson.se> <3CC58155000078A8@bgxplex3.bgx.airsys.thomson-csf.com> (added by postmaster@bgxplex3.bgx.airsys.thomson-csf.com)

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

Yes, I agree that X may be in the way.  It is also possible, if you are
logging in via telnet or some other remote service that the I/O service
tasks don't have the needed priority.

My solution for X is to bump its priority too.

Attached, find rt, a program to allow you to change the priority of any
task, and getrt a simple reporting program to get the priority of any
task.

By the way, if you have a relatively secure system, and you want to use
telnet, you can set the priority of inetd.  This way all the I/O
services and the resulting session are boosted in priority.  You must do
this ahead of time, after your task goes into a loop, its too late to
boost anything, but once you do this, you should be able to telnet into
the machine even if your task is "lost" in some loop.

-g

Nicolas Bonnefon wrote:
> 
> > My application uses the possibility to change scheduling mechanism. When
> > changing from SCHED_OTHER to SCHED_FIFO or SCHED_RR, my application causes
> > the whole Linux PC to "hang". Prior to launching my own application, I
> > launch a "superbash" application with higher priority than my own
> > application. But I am not able to switch to the window where this
> > "superbash" application is running to kill my own application. The PC
> > simply does not respond to any input from the keyboard.
> 
> Have you tried without running X ?
> A SCHED_FIFO or SCHED_RR task has ALWAYS priority over any SCHED_OTHER
> task, so if your application sits in an infinite loop without blocking, the
> window manager cannot preempt it and you simply cannot switch x-term.
> I think you should carefully debug your app in SCHED_OTHER mode first, and
> then switch to some real-time policy.
> 
> >
> > I have used this mechanism before, and I am quite confident that this
> > worked under kernel 2.4.2. Are you aware of anything that could explain
> > this behaviour?
> 
> It would be surprising, but if you were sure of that, it would deserve some
> deeper investigations !
> 
> Regards
> --
> Nicolas Bonnefon
> Radar Development/Digital Processing Engineer
> Thales Air Defence - 7-9 rue des Mathurins
> 92223 Bagneux - France
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
George Anzinger   george@mvista.com
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Real time sched:  http://sourceforge.net/projects/rtsched/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml

[-- Attachment #2: getrt.c --]
[-- Type: text/plain, Size: 1336 bytes --]

#include <sched.h>
#include <stdlib.h>

main(int args,char* argc[])
{
        struct sched_param p;
        pid_t pid;

        int policy;
        int prio,max_prio,max_rt_prio;
        char * cpolicy;

        if (args < 2) {
                pid = 0;
        }else{
                pid = atoi(argc[1]);
        }
        policy = sched_getscheduler(pid);
        sched_getparam(pid,&p);
        prio = p.sched_priority;
        max_prio = sched_get_priority_max(policy);
        max_rt_prio = sched_get_priority_max(SCHED_FIFO);

        switch(policy){
        case SCHED_OTHER:
                cpolicy = "SCHED_OTHER";
                break;
        case SCHED_RR:
                cpolicy = "SCHED_RR";
                break;
        case SCHED_FIFO:
                cpolicy = "SCHED_FIFO";
                break;
        default:
                perror("sched_getscheduler");
                exit(1);
        }
                
        if (policy == SCHED_OTHER){
                printf("%s at priority %d (MAX_PRIO(%s) = %d, MAX_PRIO(SCHED_FIFO) = %d)\n",
                       cpolicy,      prio,       cpolicy,max_prio,               max_rt_prio);
        }else{
                printf("%s at priority %d (MAX_PRIO(%s) = %d)\n",
                       cpolicy,       prio,      cpolicy, max_prio);
        }
        exit(0);
}

[-- Attachment #3: rt.c --]
[-- Type: text/plain, Size: 3205 bytes --]



/*
   rt - a utility to set the realtime priority and scheduling policy
*/

/* includes */
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <unistd.h>
#define _GNU_LIBRARY__
#include <getopt.h>

/* defines */

#define RUNSTRING "usage:  rt [-f] [-v] prio [--] runstring  \n \
 or:   rt [-f] [-v] -p PID prio\\ \n\n \
where: prio specifies the realtime priority  \n \
       -f set scheduling policy to SCHED_FIFO \n \
       -v turns on verbose mode. \n \
       -p PID specifies an existing process to modify \n \
       runstring is a process and parameters \n \
       (use '--' if runstring contains options). \n"

#define POLICY(x)  x ? x-1 ? "SCHED_RR" : "SCHED_FIFO" : "SCHED_OTHER"

/* prototypes */
void print_usage(char *[]);

/* globals */
int verbose=0;  /* 0=none, !0=verbose */


main(int argc, char *argv[])
{
        struct sched_param prio_struct;
        int policy = -1;
        int pid = 0;
        int pidopt = 0;
        int optprobs = 0; /* problems parsing? */
        
        int  c;         /* generic single character */

        /* "standard" option parsing... */
        while ( (c=getopt(argc, argv, "+fp:v?")) != EOF)
        {
        switch (c) {
                case 'f':       /* set FIFO mode */
                        policy = SCHED_FIFO;
                        break;
                case 'p':       /* read PID */  
                        sscanf(optarg,"%d",&pid); 
                        pidopt=1;
                        break;
                case 'v':
                        verbose=1;      /* verbosity */
                        break;
                case '?':       /* help? */
                        printf("%s",RUNSTRING);
                        exit(0);
                default:        /* something went wrong */
                        optprobs=1;     /* we'll deal with this problem later */
                        break;
                }
        }

        if (optprobs) {
                fprintf(stderr,RUNSTRING);
                exit(1);
        }


        if((argc - optind) < 2-pidopt) {
                print_usage(argv);
        }

        sscanf(argv[optind], "%d", &(prio_struct.sched_priority));

        /* sanity checking... */
        if ( (prio_struct.sched_priority != 0) && (policy < 0 ) ) {
                policy=SCHED_RR;
                if (verbose)
                  printf("Defaulting sched policy to %s.\n", POLICY(policy));
        }

        if ( (prio_struct.sched_priority == 0 ) && (policy != SCHED_OTHER) ) {
                policy=SCHED_OTHER;
                fprintf(stderr,"Priority of %d implies sched policy of %s.\n",
                        prio_struct.sched_priority,  POLICY(policy)); 
        }


        policy = (prio_struct.sched_priority)? policy : SCHED_OTHER;
        if( sched_setscheduler(pid,policy,&prio_struct)){
                perror("Priority out of range");
                print_usage(argv);
        }
        if ( pid ) exit(0);
        argv+=optind;   /* adjust argv to point to the runstring */
        argv++;
        execvp(argv[0],argv);
        perror("exec failed..");
}

void print_usage(char * who[])
{
        printf("%s",RUNSTRING);
        exit (1);
}


  reply	other threads:[~2002-04-26 16:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-26 12:01 SCHED_FIFO and SCHED_RR in 2.4.7-10custom kernel Eldor Rødseth (ETO)
2002-04-26 12:52 ` Nicolas Bonnefon
2002-04-26 16:25   ` george anzinger [this message]
2002-04-26 20:11   ` george anzinger

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=3CC97F64.1D9575F9@mvista.com \
    --to=george@mvista.com \
    --cc=Eldor.Rodseth@eto.ericsson.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.bonnefon@fr.thalesgroup.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.