Operating systems

Limited direct execution

Prashanth L.A.


Lecture 5 continues here

How to efficiently virtualize the CPU with control?

Direct Execution| Just run the program directly on the CPU

Direction Execution Protocol

Direction Execution Protocol

Problems with direct execution


*Problem 1:* How can the OS make sure the program doesn’t do anything that we don’t want it to do 


*Problem 2:* How does the OS stop a process from running and switch to another process

Problem 1: Restricted Operation


System Call

Trap and return


Limited Direction Execution Protocol

Problem 2: Switching Between Processes



A cooperative Approach: Wait for system calls


What if a process gets stuck in an infinite loop?

Lecture 6 starts here

A Non-Cooperative Approach: OS Takes Control


 How can the OS gain control of the CPU even if processes are not being cooperative? 


 What can the OS do to ensure a rogue process does not take over the machine?

Control, on time


The addition of a timer interrupt gives the OS the ability to run again on a CPU

Saving and Restoring Context

Context Switch



Limited Direction Execution Protocol: Timer variant