Complete Notes: System Calls & UNIX Process
Scheduling
1. System Calls for Controlling Process Context
System calls provide an interface between user programs and the operating system kernel. They
control process creation, execution, and termination.
Important System Calls with Syntax:
System Call Syntax Purpose
fork() pid_t pid = fork(); Creates a child process.
exec() execl(path, arg0, ..., NULL); Replaces process memory with new program.
wait() wait(&status); Parent waits for child completion.
exit() exit(status); Terminates a process.
getpid() pid_t id = getpid(); Gets process ID.
kill() kill(pid, SIGTERM); Sends signal to process.
nice() nice(increment); Changes process priority.
Process State Diagram:
+------ NEW ------+
|
v
+-- READY --+
| |
| v
+-- RUNNING --+ |
| ^ |
| | |
v | |
WAITING -------+
|
v
TERMINATED
A process moves from New to Ready to Running. It may move to Waiting for I/O and return to
Ready. After completion, it enters the Terminated state.
2. UNIX Process Scheduling Mechanism
Detailed Scheduling Algorithms:
1 Round Robin: Each process gets fixed CPU time (time quantum). Suitable for time-sharing
systems.
2 First Come First Serve (FCFS): Processes execute in arrival order.
3 Shortest Job First (SJF): Process with smallest execution time is scheduled first.
4 Priority Scheduling: CPU assigned based on priority level.
5 Multilevel Queue Scheduling: Separate queues for different process types.
6 Multilevel Feedback Queue: Processes move between queues based on execution behavior.
Comparison of Scheduling Algorithms:
Algorithm Advantage Disadvantage
FCFS Simple to implement Convoy effect, long waiting time
SJF Minimum average waiting time Hard to predict burst time
Round Robin Fair CPU allocation High context switching overhead
Priority Important processes executed first Starvation possible
3. Exam-Oriented Short Notes / 10-Mark Answers
Write a short note on fork() and exec():
fork() creates a new process by duplicating the parent process. The child process runs concurrently
with the parent. exec() replaces the current process memory with a new program. fork() and exec()
are often used together.
Explain Context Switching:
Context switching is the process of saving the state of one process and loading the state of another
process. It enables multiple processes to share CPU time.
Explain Round Robin Scheduling:
Round Robin scheduling assigns a fixed time slice to each process in cyclic order. It ensures
fairness and responsiveness.