0% found this document useful (0 votes)
9 views

Lecture Slides 08 081-Processes

Uploaded by

yihuangece
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lecture Slides 08 081-Processes

Uploaded by

yihuangece
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

University of Washington

Roadmap Memory & data


Integers & floats
Machine code & C
C: Java:
x86 assembly
car *c = malloc(sizeof(car)); Car c = new Car(); Procedures & stacks
c->miles = 100; c.setMiles(100);
Arrays & structs
c->gals = 17; c.setGals(17);
float mpg = get_mpg(c); float mpg =
Memory & caches
free(c); c.getMPG(); Processes
Virtual memory
Assembly get_mpg: Memory allocation
language: pushq %rbp Java vs. C
movq %rsp, %rbp
...
popq %rbp
ret
OS:
Machine 0111010000011000
100011010000010000000010
code: 1000100111000010
110000011111101000011111

Computer
system:

Processes
University of Washington

Section 8: Processes
 What is a process
 Creating processes
 Fork-Exec

Processes
University of Washington

What is a process?
 Why are we learning about processes?
 Processes are another abstraction in our computer system – the
process abstraction provides an interface between the program and the
underlying CPU + memory.
 What do processes have to do with exceptional control flow?
 Exceptional control flow is the mechanism that the OS uses to enable
multiple processes to run on the same system.

 What is a program? A processor? A process?

Processes
University of Washington

Processes
 Definition: A process is an instance of a running program
 One of the most important ideas in computer science
 Not the same as “program” or “processor”

 Process provides each program with two key abstractions:


 Logical control flow
 Each process seems to have exclusive use of the CPU
 Private virtual address space
 Each process seems to have exclusive use of main memory
 Why are these illusions important?
 How are these illusions maintained?
 Process executions interleaved (multi-tasking)
 Address spaces managed by virtual memory system – next course topic

Processes
University of Washington

Concurrent Processes
 Two processes run concurrently (are concurrent) if their
instruction executions (flows) overlap in time
 Otherwise, they are sequential
 Examples:
 Concurrent: A & B, A & C
 Sequential: B & C

Process A Process B Process C

time

Processes
University of Washington

User View of Concurrent Processes


 Control flows for concurrent processes are physically disjoint
in time
 CPU only executes instructions for one process at a time
 However, we can think of concurrent processes as executing
in parallel

Process A Process B Process C

time

Processes
University of Washington

Context Switching
 Processes are managed by a shared chunk of OS code
called the kernel
 Important: the kernel is not a separate process, but rather runs as part
of a user process
 Control flow passes from one process to another via a context
switch… (how?)
Process A Process B

user code

kernel code context switch

time user code

kernel code context switch

user code

Processes

You might also like