System calls and OS structure Flashcards
What are the two main functions of an operating system?
- Providing abstractions to user programs.
- Managing the computer’s resources.
What does the interface between user programs and the operating system primarily deal with?
Dealing with abstractions such as file creation, writing, reading, and deletion.
What is the purpose of system calls in the operating system?
System calls allow user programs to request services from the operating system, such as reading data from a file.
How are system calls invoked from C programs?
System calls are typically invoked by calling library procedures with the same name as the system call.
What happens when a process makes a system call?
The process executes a trap instruction to transfer control to the operating system, which carries out the system call and returns control to the instruction following the system call.
How does the operating system determine the requested service in a system call?
The operating system inspects the parameters passed by the calling process to determine the specific system call and its required actions.
What is the purpose of the TRAP instruction in the system-call mechanism?
The TRAP instruction switches the processor from user mode to kernel mode and starts execution at a fixed address within the kernel.
How are system calls handled by the operating system?
The system-call handler, determined by the system-call number, is invoked to perform the requested service.
What happens if a system call encounters an error or invalid parameter?
The system call sets the return value to -1 and stores the error number in a global variable called errno.
How does the fork system call work in the process management of an operating system?
The fork system call creates an exact duplicate of the original process, including all its resources, and returns the process ID (PID) of the child to the parent.
What are the three system calls related to directory managemente?
mkdir
rmdir
link
What is the purpose of the mkdir system call?
The mkdir system call is used to create a new empty directory.
How does the link system call work?
The link system call allows the same file to appear under two or more names in different directories.
How does the rmdir system call function?
The rmdir system call is used to remove an empty directory from the file system.
What happens when a file is linked using the link system call?
When a file is linked, changes made to the file by any user are instantly visible to other users who have access to the file. It creates multiple directory entries that refer to the same file.