Everything Penguin

Focusing on Linux-based Operating Systems
htDig Search:

Operating Systems
  • /pub/OS/Linux

  • Storage
  • File Systems
  • HPC
  • /pub/Storage

  • Networking
  • /pub/Networking

  • Network Services
  • /pub/NetworkServices

  • Security
  • /pub/Security
  • Keytool/OpenSSL

  • Clustering
  • HA
  • DRM

  • Development
  • Design
  • C/C++
  • Java
  • Perl
  • Python
  • Shell
  • Web / J2EE

  • Not Linux ?
  • BSD
  • HP-UX
  • Mac
  • Solaris
  • VM
  • Windows
  • /pub/OS

  • Other
  • /pub
  • /pub/3rdParty
  •  Parent Directory

    Linux Scheduling 2 - Using Scheduling Classes
    Brett Lee
    ====================================================
    
    Continuing from where we left off in Linux Scheduling 1.
    
    
      Recall the scheduling classes presented were:
    
        First In First Out (SCHED_FIFO)
            System Priority Range: 0 through 99
    
        Real Time Round Robin (SCHED_RR)
            System Priority Range: 0 through 99
    
        Time Sharing (SCHED_OTHER)
            User Priority (nice) Range: -19 through 20
            System Priority Range: 100 through 139
    
        Batch (SCHED_BATCH)
            User Priority (nice) Range: 0 through 0
            System Priority Range: 120 through 120
    
    
    Some generalized statements about process scheduling.
    
    
        ** Note that newer schedulers, like CFS, may make some (TS) statements
        ** obsolete.
    
        1.  When a user runs a typical job, it will run in the Time Sharing (TS)
            class and it will start in the priority range 120 (nice 0).  Based
            upon how long it has run (time quantum) it may be moved in priority
            between 120 and 139 (nice 20).
        2.  TS jobs can be elevated to the range 100-119, but this requires privs.
        3.  Jobs in RR class run in the priority range 0-99 and obey fairness with
            other jobs at that priority based on time quanta.
        4.  Jobs in FIFO class run in the priority range 0-99 for as long as they
            want or can (block for IO, get interrupted by an IRQ, etc.).
    
    
    
    As discussed previously, running a job in the time sharing (TS) class occurs
      by default.
    
      So how does one run processes in the other scheduling classes?
    
      The answer is either programmatically or from the command line.
    
      Here is how to do the latter:
    
      1.  Using the 'chrt' command from util-linux (formerly schedutils):
    
      [root@linux ~]# chrt -h
      chrt (util-linux 2.13-pre7)
      usage: chrt [options] [prio] [pid | cmd [args...]]
      manipulate real-time attributes of a process
        -b, --batch                        set policy to SCHED_BATCH
        -f, --fifo                         set policy to SCHED_FF
        -p, --pid                          operate on existing given pid
        -m, --max                          show min and max valid priorities
        -o, --other                        set policy to SCHED_OTHER
        -r, --rr                           set policy to SCHED_RR (default)
        -h, --help                         display this help
        -v, --verbose                      display status information
        -V, --version                      output version information
    
      You must give a priority if changing policy.
    
      Report bugs and send patches to <rml@tech9.net>
    
      [root@linux ~]# chrt -m
      SCHED_OTHER min/max priority    : 0/0
      SCHED_FIFO min/max priority     : 1/99
      SCHED_RR min/max priority       : 1/99
      SCHED_BATCH min/max priority    : 0/0
    
      [root@linux ~]# ps -efcl | grep top | grep -v grep
      0 S brett    30028 29684 TS   23 -  3177 -      15:58 pts/3    00:00:00 top
    
      [root@linux ~]# chrt -p 30028
      pid 30028's current scheduling policy: SCHED_OTHER
      pid 30028's current scheduling priority: 0
    
      [root@linux ~]# chrt -p 99 30028
    
      [root@linux ~]# chrt -p 30028
      pid 30028's current scheduling policy: SCHED_RR
      pid 30028's current scheduling priority: 99
    
      NOTE: the process was set to the default of SCHED_RR
    
      [root@linux ~]# ps -efcl | grep top | grep -v grep
      0 S brett    30028 29684 RR  139 -  3177 -      15:58 pts/3    00:00:00 top
    
      For more, see:
      http://www.cyberciti.biz/faq/howto-set-real-time-scheduling-priority-process/
    
    
    
      2.  Another method (for Solaris fans) is to use 'priocnl':
    
    
      [root@linux ~]# cvs -d:pserver:anonymous@heirloom.cvs.sourceforge.net:/cvsroot/heirloom \
    	co -P heirloom/priocntl
      cvs checkout: Updating heirloom/priocntl
      U heirloom/priocntl/Makefile.mk
      U heirloom/priocntl/priocntl.1
      U heirloom/priocntl/priocntl.c
    
      [root@linux ~]# cd heirloom/priocntl && make priocntl
      cc     priocntl.c   -o priocntl
    
      [root@linux priocntl]# ./priocntl -l
      CONFIGURED CLASSES
        (Shows the configured classes as seen above)
    
      Investigating 
      [root@linux priocntl]# ./priocntl -d 29706
      REAL TIME PROCESSES
          PID    RTPRI       TQNTM
        29706       1          99
    
      Next, set the class to RT with a priority of 50:
      [root@linux priocntl]# ./priocntl -s -c RT -p 50 -i pid 29706
    
      [root@linux priocntl]# ./priocntl -d 29706
      REAL TIME PROCESSES
          PID    RTPRI       TQNTM
        29706      50          99
    
      [root@linux priocntl]# ps -efc | grep top
      brett    29706 29684 RR   90 15:14 pts/3    00:00:00 top
    
      For more on priocntl, see:
      http://dsstos.blogspot.com/2010/01/understanding-cpu-time-as-oracle-wait.html
    
    
    

    Other Sites

    RFC's
  • FAQ's
  • IETF
  • RFC Sourcebook

  • Linux
  • Linux - Intro
  • Linux Kernel
  • Linux Kernel (LKML)
  • Bash - Intro
  • Bash - Advanced
  • Command Line
  • System Administration
  • Network Administration
  • Man Pages (& more)
  • More Guides
  • Red Hat Manuals
  • HOWTO's

  • Reference/Tutorials
  • C++ @ cppreference
  • C++ @ cplusplus
  • CSS @ echoecho
  • DNS @ Zytrax
  • HTML @ W3 Schools
  • Java @ Sun
  • LDAP @ Zytrax
  • Linux @ YoLinux
  • MySQL
  • NetFilter
  • Network Protocols
  • OpenLDAP
  • Quagga
  • Samba
  • Unix Programming



  • This site contains many of my notes from research into different aspects of the Linux kernel as well as some of the software provided by GNU and others. Thouugh these notes are not fully comprehensive or even completetly accurate, they are part of my on-going attempt to better understand this complex field. And, they are your to use.

    Should you wish to report any errors or suggestions, please let me know.

    Should you wish to make a donation for anything you may have learned here, please direct that donation to the ASPCA, with my sincere thanks.

    Brett Lee
    Everything Penguin

    The code for this site, which is just a few CGI scripts, may be found on GitHub (https://github.com/userbrett/cgindex).

    For both data encryption and password protection, try Personal Data Security (https://www.trustpds.com).


    "We left all that stuff out. If there's an error, we have this routine called 'panic', and when its called, the machine crashes, and you holler down the hall, 'Hey, reboot it.'"

        - Dennis Ritchie on Unix (vs Multics)


    Google
    [ Powered by Red Hat Linux ] [ Powered by Apache Server] [ Powered by MySQL ]

    [ Statistics by AWStats ]