Processes and System calls Flashcards
(11 cards)
What is a Process
- A process is a program that’s running
- Program loader,
invoked by exec( ), retrieves and unpacks executable - ## Note a thread is a flow of execution within process
Processes are defined by their context..
CPU Registers
Memory Layout
Open Files
On-going communication state
PCB
Basic Process Control Block holds all the essential management information/context for a process. There’s one PCB per process.
Process state,
Process ID,
Priority
Process Hierarchy
- Processes can spawn child processes
- Each child has parent process– Ultimately responsible for resources used by child
Creating a Child Process
In Unix this carried out by fork( ) system call– Returns child’s Process ID to parent and 0 to child
Process heap
The heap is a part of a process’s memory where it can dynamically request more memory while running — useful when you don’t know in advance how much memory you’ll need.
Process Stack
The stack is a part of a process’s memory used to keep track of function calls like a to-do list for the CPU.
- Stack grows and shrinks as functions are called and return.
- On x86 systems, it grows downward
-
what is System calls
User programs can’t directly Communicate with (most) hardware as unrestricted access would allow any program to read/ change anything so System Calls Offer standard interface to kernel/ OS functions meaning they communicate to the OS.
System calls Provides access control mechanism Single point of entry that can check all parameter
examples of system calls
read() → read data from a file or input
write() → write data to a file or output
fork() → create a new process
exec() → run a new program
exit() → end a process
open(), close() → manage files
What happens during a system call?
The program switches to kernel mode, the OS performs the action, then control returns to the program.