Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 13: System Calls


❑ setpriorityandgetpriorityset and get the priority of a process and are therefore key
system calls for scheduling purposes.
❑ Linux is noted not only for supporting different process priorities, but also for pro-
viding a wide variety of scheduling classes to suit the specific time behavior and time
requirements of applications.sched_setschedulerandsched_getschedulerset and
query scheduling classes.sched_setparamandsched_getparamset and query additional
scheduling parameters of processes (currently, only the parameter for real-time priority
is used).
❑ sched_yieldvoluntarily relinquishes control even when CPU time is still available to the
process.

ModulesSystem calls are also used to add and remove modules to and from the kernel, as described
in Chapter 7.
❑ init_moduleadds a new module.
❑ delete_moduleremoves a module from the kernel.

FilesystemAll system calls relating to the filesystem apply to the routines of the VFS layer discussed in
Chapter 8. From there, the individual calls are forwarded to the filesystem implementations that
usually access the block layer. System calls of this kind are very costly in terms of resources and
execution time.
❑ Some system calls are used as a direct basis for userspace utilities of the same name that
create and modify the directory structure:chdir,mkdir,rmdir,rename,symlink,getcwd,
chroot,umask,andmknod.
❑ File and directory attributes can be modified usingchownandchmod.
❑ The following utilities for processing file contents are implemented in the standard library
and have the same names as the system calls:open,close,readandreadv,writeand
writev,truncateandllseek.
❑ readdirandgetdentsread directory structures.
❑ link,symlink,andunlinkcreate and delete links (or files if they are the last element in a
hard link);readlinkreads the contents of a link.
❑ mountandumountare used to attach and detach filesystems.
❑ pollandselectare used to wait for some event.
❑ execveloads a new process in place of an old process. It starts new programs when used
in conjunction withfork.

Memory ManagementUnder normal circumstances, user applications rarely or never come into contact
with memory management system calls because this area is completely shielded from the standard
library — by themalloc,balloc,andcallocfunctions in the case of C. Implementation is usually
programming language-specific because each language has different dynamic memory manage-
ment needs and often provides features like garbagecollection that require sophisticated allocation
of the memory available to the kernel.
❑ In terms of dynamic memory management, the most important call isbrk,whichmodifies
the size of the process data segment. Programs that invokemallocor similar functions
(almost all nontrivial code) make frequent use of this system call.
Free download pdf