Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 13: System Calls


❑ nicesets the priority of normal processes by assigning a number between−20 and 19 in
descending order of importance. Only root processes (or processes with theCAP_SYS_NICE
permission) are allowed to specify negative values.
❑ setrlimitis used to set certain resource limits, for example, CPU time or the maximum
permitted number of child processes.getrlimitqueries the current limits (i.e., maximum
permitted values), andgetrusagequeries current resource usage to check whether the
process is still within the defined resource limits.

Time OperationsTime operations are critical, not only to query and set the current system time, but also
to give processes the opportunity to perform time-based operations, as described in Chapter 15:
❑ adjtimexreads and sets time-based kernel variables to control kernel time behavior.
❑ alarmandsetitimerset up alarms and interval timers to defer actions to a later time.
getitimerreads settings.
❑ gettimeofdayandsettimeofdayget and set the current system time, respectively. Unlike
times, they also take account of the current time zone and daylight saving time.
❑ sleepandnanosleepsuspend process execution for a defined interval;nanosleepdefines
high-precision intervals.
❑ timereturns the number of seconds since midnight on January 1, 1970 (this date is the
classic time base forUnixsystems).stimesets this value and therefore changes the current
system date.


Signal HandlingSignals are the simplest (and oldest) way of exchanging limited information between
processes and of facilitating interprocess communication. Linux supports not only classic sig-
nals common to allUnixlook-alikes but also real-time signals in line with the POSIX standard.
Chapter 5 deals with the implementation of the signal mechanism.
❑ signalinstalls signal handler functions.sigactionis a modern, enhanced version that
supports additional options and provides greater flexibility.
❑ sigpendingchecks whether signals are pending for the process but are currently blocked.
❑ sigsuspendplaces the process on the wait queue until a specific signal (from a set of
signals) arrives.
❑ setmaskenables signal blocking, whilegetmaskreturns a list of all currently blocked
signals.
❑ killis used to send any signals to a process.
❑ The same system calls are available to handle real-time signals. However, their function
names are prefixed withrt_. For example,rt_sigactioninstalls a real-time signal han-
dler, andrt_sigsuspendputs the process in a wait state until a specific signal (from a set
of signals) arrives.
In contrast to classic signals, 64 different real-time signals can be handled on all
architectures — even on 32-bit CPUs. Additional information can be associated with
real-time signals, and this makes the work of (application) programmers a little easier.


SchedulingScheduling-related system calls could be grouped into the process management category
because all such calls logically relate to system tasks. However, they merit a category of their
own due simply to the sheer number of manipulation options provided by Linux to parameterize
process behavior.

Free download pdf