Lecture 5: Processes

Reading: OSTEP, up to Ch. 6

Warm-up Question

Introduction

“An OS is a land of magic and illusions”

Processes

Limited Execution and Time Sharing

Time Process 1 Process 2 Process 3
0 starts starts starts
1 Running Ready Ready
2 Running Ready Ready
3 Running Ready Ready
4 Running Ready Ready
5 Ready Running Ready
6 Ready Running Ready
7 Ready Running Ready
8 Ready Running Ready
9 Ready Ready Running
10 Ready Ready Running
11 Ready Ready Running
12 Ready Ready Running
13 Running Ready Ready
14 Running Ready Ready
15 Running Ready Ready
16 done Running Ready
17 Running Ready
18 Running Ready
19 Running Ready
20 Ready Running
21 Ready Running
22 Running done
23 Running
24 Running
25 done

scheduling

The act of letting the process take control of the CPU

descheduling

Removing the process from the CPU to use it for something else


           deschedule
+---------+ -------> +-------+
| Running |          | Ready |
+---------+ <------- +-------+
        \   schedule   ^ 
   I/O   \            /  I/O
requested \          /  completed
           v        /   
          +---------+    
          | Blocked |    
          +---------+

Switching Between Processes

Cooperative Multitasking

Preemption

Mechanism: Exceptional Control Flow

  1. Asynchronous: (Hardware) Interrupts
  2. Synchronous
    1. Traps
      • Intentionally triggered by the software - system calls, breakpoints
      • System calls are the primary mechanism of how user programs can interact with the OS
      • Used to request a service from the OS - The service code needs to execute in privileged mode
    2. Faults
      • Unintentionally triggered
      • Potentially recoverable
      • Page faults, floating point exceptions
    3. Aborts
      • Unintentionally triggered
      • Unrecoverable
      • Illegal instruction, RAM parity errors

To be continued…