Understanding the Linux Kernel by Daniel Pierre Bovet & Marco Cesati
Author:Daniel Pierre Bovet & Marco Cesati [Bovet, Daniel Pierre & Cesati, Marco]
Language: fra
Format: epub
Tags: Informatique
ISBN: 9780596002138
Google: 9yIEji1UheIC
Publisher: O'Reilly
Published: 2002-07-14T22:00:00+00:00
I l@ve RuBoard
11.3 System Calls Related to Scheduling
Several system calls have been introduced to allow processes to change their priorities and scheduling policies. As a general rule, users are always allowed to lower the priorities of their processes. However, if they want to modify the priorities of processes belonging to some other user or if they want to increase the priorities of their own processes, they must have superuser privileges.
11.3.1 The nice( ) System Call
The nice( )[8] system call allows processes to change their base priority. The integer value contained in the increment parameter is used to modify the nice field of the process descriptor. The nice Unix command, which allows users to run programs with modified scheduling priority, is based on this system call.
[8] Since this system call is usually invoked to lower the priority
of a process, users who invoke it for their processes are "nice" to
other users.
The sys_nice( ) service routine handles the nice( ) system call. Although the
increment parameter may have any value, absolute values larger than 40 are trimmed down to 40. Traditionally, negative values correspond to requests for priority increments and require superuser privileges, while positive ones correspond to requests for priority decrements. In the case of a negative increment, the function invokes the capable( ) function to verify whether the process has a CAP_SYS_NICE capability. We discuss that function, together with the notion of capability, in Chapter 20. If the user turns out to have
the capability required to change priorities, sys_nice( ) adds the value of increment to the nice field of current. If necessary, the value of this field is trimmed down so it won't be less than - 20 or greater than + 19.
The nice( ) system call is maintained for backward compatibility only; it has been replaced by the setpriority( ) system call described next.
11.3.2 The getpriority( ) and setpriority( ) System Calls
The nice( ) system call affects only the process that invokes it. Two other system calls, denoted as getpriority( ) and setpriority( ), act on the base priorities of all
processes in a given group. getpriority( ) returns 20 minus the lowest nice field value among all processes in a given group—that is, the highest priority among that processes; setpriority( ) sets the base priority of all processes in a given group to a given value.
The kernel implements these system calls by means of the sys_getpriority( ) and
sys_setpriority( ) service routines. Both of them act essentially on the same group of parameters:
which
The value that identifies the group of processes; it can assume one of the following: PRIO_PROCESS
Selects the processes according to their process ID (pid field of the process descriptor).
PRIO_PGRP
Selects the processes according to their group ID (pgrp field of the process descriptor).
PRIO_USER
Selects the processes according to their user ID (uid field of the process descriptor).
who
The value of the pid, pgrp, or uid field (depending on the value of which) to be used for selecting the processes. If who is 0, its value is set to that of the
corresponding field of the current process.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7324)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3417)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2313)
The Infinite Retina by Robert Scoble Irena Cronin(2181)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2100)
Docker on Windows by Stoneman Elton(2081)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(1832)
Computers For Seniors For Dummies by Nancy C. Muir(1769)
Hands-On Linux for Architects by Denis Salamanca(1738)
The Old New Thing by Raymond Chen(1719)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(1701)
Filmora Efficient Editing by Alexander Zacharias(1550)
MCSA Windows Server 2016 Study Guide: Exam 70-741 by William Panek(1479)
Installing and Configuring Windows 10: 70-698 Exam Guide by Bekim Dauti(1412)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(1397)
Embedded Systems Architecture by Daniele Lacamera(1377)
Learn Computer Forensics by William Oettinger(1355)
Mastering Kubernetes by Gigi Sayfan(1349)
Database Reliability Engineering: Designing and Operating Resilient Database Systems by Campbell Laine & Majors Charity(1348)