1 of 13

ECS 150: Operating Systems

Direct execution

2 of 13

Administrative

Project 1: Due on Friday

  • Reminder: use the source
  • Video for how to setup VS Code for Project 1

Project 2: Out on Friday

Zoom lecture recording seems to have worked, will continue to try to capture lectures that way

3 of 13

Finishing up dish…

4 of 13

Address spaces and memory

  • Process = one or more thread in an address space
  • Thread: stream of execution
    • Unit of concurrency
  • Address space: memory space that threads use
    • Unit of data

5 of 13

Types of data in the address spaces

0xffffffff

0x00000000

Code segment

Data segment

Stack segment

6 of 13

Stacks

A(int tmp) {

B();

}

B() {

C();

}

C() {

A(2);

}

Start by calling A(1)

A(tmp=1)

C

A(tmp=2)

B

7 of 13

Address space abstraction

  • Address space: all the memory data for a process
    • Program code, stack, data segment

  • Hardware interface (physical reality)
    • One memory, small, shared
  • Application interface (illusion)
    • Each proc has own memory, large

8 of 13

Illusions provided by address space

  • Address independence
    • E.g., Fork
  • Protection
    • E.g., browser password storage
  • Virtual memory
    • E.g., ML

9 of 13

Uni-programming

  • 1 process runs at a time
  • Always load process into the same spot
  • How do you switch processes?
  • What abstractions does this provide?
  • Problems?

10 of 13

Multi-programming

  • Multi-programming: more than one proc in memory at a time
    • Need address translation
    • Need protection
  • Address translation
    • Avoid conflicting addresses
    • Static: before you execute
    • Dynamic: during execution, could change

11 of 13

Dynamic translation

  • Translate every memory reference from virtual address to physical address
    • Virtual address: an address viewed by the user process
    • Physical address: an address viewed by the physical memory

12 of 13

Dynamic address translation

  • Translation enforces protection
    • One process can’t even refer to another process’s address space
  • Translation enables virtual memory
    • A virtual address only needs to be in physical memory when it is being accessed
    • Change translations on the fly as different virtual addresses occupy physical memory
  • Do you need hardware support?

User

process

Translator

(MMU)

Physical

memory

Virt addr

Phys addr

13 of 13

Dynamic address translation

  • Lots of ways to implement, remember the big picture
  • Tradeoffs:
    • Flexibility (e.g., sharing, growth, virtual memory)
    • Size of translation data
    • Speed of translation

User

process

Translator

(MMU)

Physical

memory

Virt addr

Phys addr