Lecture 5: System Calls Flashcards
System calls do what?
Provide an interface to the OS’s services
System calls are written in what language?
C, C++, sometimes Assembly
How do you invoke system calls?
Through using Function Calls provided to the programmer via an API
How are parameters passed from Function Calls to System Calls (to the OS’s services)?
3 methods:
1) Registers (pass parameters to registers)
2) Block
3) Stack
Define:
1) Registers
2) Block
3) Stack
1) Registers: pass parameters to registers
2) Block : parameters stored in a block or table, in memory, and address of block passed as a parameter in a register
3) Stack: Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system
Out of the 3 OS-parameter-passing methods, which are limiting / not limiting?
Block and Stack do not limit the number or length of parameters being passed. Registers are limited (only fewer than 6 parameters can be passed to registers)
A system call number has an alternative name, what is it?
Read_Code (this points to where the actual code is located)
A system call number is associated with what?
with each system call.
What is a System Call Handler Table?
A table that the OS maintains which contains all the system call numbers (each entry is indexed by the system call number itself). Each entry points to the actual code to run the system call.
Define: TRAP Instruction
Instruction that switches the CPU from User mode to Supervisor (kernel) mode so the predetermined OS instructions can execute as a separate process.
What happens to the user process(es) when the TRAP instruction is used?
User process’s state is saved so the OS instructions needed can be executed. When finished, then the user process can execute.
List the steps in making a system call (5 Steps)
Step 1: After function call calls a system call, the calling program pushes the parameters onto the stack. (NOTE: There is a stack entry for each call)
Step 2: Input parameters are passed into registers or to a block
Step 3: TRAP instruction is executed
Step 4: System call handler code is executed
Step 5: After execution, control returns to the library procedure (system function)
How does a process find out about reading data from disk memory being completed?
1) Polling
2) Interrupt
What does the interrupt handler do:
Saves processor state: CPU registers of interrupted process are saved into a data structure in memory
Runs code to handle the I/O
Restores processor state: CPU registers values stored in memory are reloaded
PC is set back to PC of interrupted process