How to create the illusion of multiple CPUs

Context Switching

Context Switching - When a program switches from running one program then switches to run another program, and back to running the original program

Context switching has the mechanism that the process is loaded into memory, chunks are ran, then the state of the process is saved. The OS switches to another process, and when switching back to the original process, the original process state is reloaded into memory, and the next set of instructions of the program are executed, and then the state is saved. The OS then goes to another process and repeats the steps. Switching back to the original process, its state is reloaded and ran again.

Time Sharing

Allowing one process to run for X amount of time, the suspending that process to allow anohter process to run for X amount of time.

This time sharing mechanism is what allows for context switching going and back between processes for X amount of time.

"
Concurrent Process

Allow multiple processes to run concurrently. If their flows overlap in time they are concurrent, else they are sequentialy.

How do we create a process

First the code of the program must be loaded into memory by the OS. The code is loaded into memory blocks.

The OS must allocate memory for the run-time stack used to store local variables, function parameters, and return addresses.

A heap is needed for requesting dynamically allocated data. Linked lists, hash tables, trees are such data structures

1. Running – a process is running on a processor, and is executing instructions

2. Ready – process is ready to run, but the OS has stopped it from running at this moment

3. Blocked – the process has performed some kind of operation that makes it not ready to run until some other event has taken place, i.e. a process initiates an I/O request but is blocked so some other process can use the processor (lets another process run)

4. Scheduled – process is moved from ready to running state, scheduler decides what processor gets to go first, second, third etc.

5. Descheduled – process went from running to ready

previous: lecture 2