Back
To Chapter 2
Introduction To Processes
Definition of Process
-
an instance of running program
-
the progress through the set of states in program's life
Operating system's responsibilities
-
Scheduling - who runs next?
Any modern OS can do several things at once:
-
Running a user program
-
Reading from a disk
-
Outputting text to a screen or printer
One CPU with n processes: CPU execute each for 1 millisecond
Pseudo parallelism - under multiprogramming environment, CPU's time
is switched from one process to another process.
Optimize CPU usage
-
Messages - inter process communication (IPC)
-
Synchronous, e.g. read & write
-
Asynchronous, e.g. signals, interrupt
User does not expect to receive a message and sender just goes ahead
to send it.
-
Create a process
fork(), exec()
-
Terminate a process
OS tries to access some memory space which should not belong to this
process, then this process is terminated.
-
Context switching
Save all information before preempted:
the process table
An array of structures typically contain e.g.
-
memory address
-
saved registers
-
time - how much time used for OS, for Appliactions
-
priority
-
process' state
MINIX
special process
init() in boot image
-
init run as first process
-
Determins how many terminals
-
Run (fork()) a process for each
-
Each waits for a login
-
Login - executes shell
init
/ / |
\ \
term2 term1
|
|
login
|
shell
/ / | \ \
CMD1 ................. (n processes)
MINIX Process States (See Figure
2-2 on page 51)
1. I/O interrupt: A process is waiting for something
before it can start to run e.g. waiting for input.
This process will be switched
from Running to Blocked.
2. I/O completed: The process got the request
complete.
This process will be switched
from Blocked to Ready.
From
Blocked state, it can not go Running state and must go to Ready state.
3. Scheduler Dispatch: The process
get scheduled
This process will be switched
from Ready to Running.
4. Preempted: Interrupt, wait
This process will be switched
from Running to Ready.
The five general process activity states:
(See the state diagram describing
how a process transitions from one state to the next)
-
New - Process being created.
-
Running - Instructions are being executed in CPU.
-
Waiting - The process is waiting for some event to occur.
-
Ready - The process is waiting to be assigned to CPU.
-
Terminated - Process is done.