Lecture 3
Lecture 3
Lecture 3
Systems
Lecture 3
Agenda for Today
Process concept
Process scheduling concepts
Process creation and termination
Recap of the lecture
What is a process?
Process – a program in execution; process
execution must progress in sequential
fashion.
A process consists of:
Code (text) section
Data section
Stack
Heap
Environment
CPU state (program counter, etc.)
Process control block (PCB)
CPU and I/O Bound
Processes
Processes can be:
I/O-bound process – spends more time doing
I/O than computations, many short CPU
bursts.
I/O Burst CPU Burst I/O Burst CPU Burst
...
pid = fork();
if (pid == 0) {
/* Code for child */ Child Process pid = 0
...
}
else {
/* Code for parent */
...
}
... Kernel Space
}
fork()—Inherits from
the Parent
The child process inherits the following
attributes from the parent:
Environment
Open file descriptor table
Signal handling settings
Nice value
Current working directory
Root directory
File mode creation mask (umask)
Etc.
fork()—Child Differs
from the Parent
The child process differs from the
parent process:
Different process ID (PID)
Different parent process ID (PPID)
Child has its own copy of parent’s file
descriptors
Etc.
fork()—Reasons for
Failure
Maximum number of processes allowed to
execute under one user has exceeded
Maximum number of processes allowed
on the system has exceeded
Not enough swap space