

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of system calls, their role in operating systems, and how they differ from library functions. It covers common system calls related to file i/o, process control, memory management, time management, and interprocess communication. The document also discusses the differences between system calls and library functions, their impact on performance, and how to access their man pages.
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


An operating system (O/S) is a program with two jobs: it manages the resources of the computer (peripherals, files, memory, etc.) and it manages all other programs running on the computer.
(kernel)
printer memory files
application (program)
application (program)
application (program)
resources of computer
system calls
The programs we write access the resources of the computer by calling functions executed by the kernel. These functions are called system calls. A collection of system calls is sometimes referred to as an application program interface (API).
There are dozens of system calls supported by any linux or unix kernel. Some common examples include (none of these lists is all-inclusive):
Other system calls include those used for message passing, shared memory, semaphores, thread management, and network management (sockets). All of these are beyond the scope of this course, and are typically covered in a full operating systems class.
Note that we have already seen some of these system calls. Others look a lot like other functions we have already seen. For example, what is the difference between open() and fopen(), or read() and fread()? The former are system calls, meaning the code executed is part of the kernel. The latter are C standard library calls. The code for them is sitting in /usr/lib/libc.a, where we have already seen the code for printf() and other functions. The calling of those functions is handled differently. If a library is linked statically, then the code is already part of the running program, and is executed directly. If a library is linked dynamically, then the kernel handles it (the details beyond the scope of this class).
For most programs, the differences between system calls and library calls are moot. However, when coding for device drivers or other low-level operations, or for serious applications, the differences can become very important:
As an example of the latter, consider again the open()/read()/write()/close versus fopen()/fread()/fwrite()/fclose() function calls. The former are system calls, while the latter are C standard library function calls. The latter are more efficient, because they use buffering. When an fread() call is made, more than the requested amount is read() from the file. The extra bytes are held in a buffer, local to the C standard library, and not directly accessible by your program. When your program next calls fread(), it may be able to satisfy the request using bytes already in its buffer, eliminating the need for another read() system call.
The man pages for system calls are stored in a separate folder than the man pages for library calls, and both are stored separate from system programs:
man 2 stat [provides man page for system call stat()]