System Call Flashcards
(43 cards)
What is a System Call?
A system call is a programmatic way for a user application to request a service from the operating system (OS). It acts as an interface between user programs and the kernel.
Why are System Calls Needed?
System calls are needed to allow user programs to perform tasks that require privileged access to hardware or kernel resources, enforce security, and provide a consistent interface for applications.
How do System Calls Work?
1) The user program invokes a system call using a library function. 2) A software interrupt (trap) switches the CPU from user mode to kernel mode. 3) The kernel executes the requested operation. 4) The kernel returns the result to the user program.
What are the Types of System Calls?
1) Process Control, 2) File Management, 3) Device Management, 4) Information Maintenance, 5) Communication, 6) Protection.
What is Process Control in System Calls?
Process control system calls manage processes, such as creating, terminating, or executing them. Examples: fork()
, exec()
, exit()
, wait()
.
What is File Management in System Calls?
File management system calls manipulate files, such as creating, reading, writing, or deleting them. Examples: open()
, read()
, write()
, close()
, unlink()
.
What is Device Management in System Calls?
Device management system calls manage hardware devices, such as printers or disks. Examples: ioctl()
, read()
, write()
.
What is Information Maintenance in System Calls?
Information maintenance system calls retrieve or set system information. Examples: getpid()
, time()
, sysinfo()
.
What is Communication in System Calls?
Communication system calls facilitate inter-process communication (IPC). Examples: pipe()
, shmget()
, msgget()
.
What is Protection in System Calls?
Protection system calls manage access control and permissions. Examples: chmod()
, chown()
.
What is a System Call Number?
A system call number is a unique identifier assigned to each system call. The kernel uses this number to identify the requested service.
What is a System Call Table?
A system call table is a data structure in the kernel that maps system call numbers to their corresponding functions.
What is a Software Interrupt?
A software interrupt (e.g., int 0x80
on x86) triggers a switch from user mode to kernel mode to execute a system call.
What is Context Switching in System Calls?
Context switching is the process of saving the current state of a process (registers, program counter) and switching to kernel mode to execute a system call.
What is the Overhead of a System Call?
The overhead of a system call includes context switching, kernel mode execution, and potential delays due to hardware access.
How can System Call Overhead be Reduced?
System call overhead can be reduced by using buffered I/O, batching operations, or minimizing the number of system calls.
What is the Role of the Kernel in System Calls?
The kernel executes system calls, manages hardware resources, and ensures security and isolation between processes.
What is the Difference Between a System Call and a Library Function?
A system call interacts with the kernel, while a library function runs in user space. Library functions may internally use system calls.
What is the Purpose of the fork()
System Call?
The fork()
system call creates a new process by duplicating the current process. The new process is called the child process.
What is the Purpose of the exec()
System Call?
The exec()
system call replaces the current process with a new program. It loads the new program into memory and starts its execution.
What is the Purpose of the wait()
System Call?
The wait()
system call allows a parent process to wait for a child process to terminate and retrieve its exit status.
What is the Purpose of the pipe()
System Call?
The pipe()
system call creates a pipe, which is a unidirectional communication channel between two processes.
What is the Purpose of the open()
System Call?
The open()
system call opens a file and returns a file descriptor, which is used for subsequent file operations.
What is the Purpose of the read()
System Call?
The read()
system call reads data from a file or device into a buffer.