1 of 21

ECS 150: History of OS and introduction to processes

Sam King

2 of 21

Processes and concurrency

  • Motivation
    • OSes getting complex
    • Multiple users, programs, I/O devices, etc.
    • How to manage this complexity?

  • Decompose or separate hard problems into simpler ones

3 of 21

main() {

getInput();

computeResult();

printOutput();

}

getInput() {

cout();

cin();

}

computeResult() {

sqrt();

pow();

}

printOutput() {

cout();

}

Programs decompose into several rows

main

getInput

cout

4 of 21

  • Processes decompose mix of activities running on a processor into several parallel tasks (columns)

  • Each job can work independently of the others
  • Remember, for any area of OS, ask:
    • What interface does the hardware provide?
    • What interface does the OS provide?

Job 1

Job 2

Job 3

5 of 21

What’s in a process?

  • Definition of a process
    • (informal) a program in execution. A running piece of code along with all the things the program ca read/write
      • Note: process != program
    • (formal) one of more threads in their own address space
  • Play analogy

6 of 21

  • Thread
    • Sequence of executing instructions from a program (i.e., the running computation)
    • Active
    • Play analogy

  • Address space
    • All the data in the process uses as it runs
    • Passive (acted upon by the thread)
    • Play analogy: all the object on the stage in a play

7 of 21

Key abstractions

  • Process
  • File system
  • File descriptor
    • Files
    • Pipes
    • Sockets
    • Devices
    • And more

8 of 21

Examples!

  • Command line examples
  • Simple example about file descriptors

9 of 21

OS architectures

10 of 21

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

User mode

Kernel mode

11 of 21

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

Typical interactions w system

12 of 21

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

Shared libraries

13 of 21

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

High-level abstractions (e.g., file system)

14 of 21

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

Low-level (process switch)

15 of 21

OS architectures

  • OS developers paranoid
    • Buggy software
    • Unreliable hardware
    • Users cannot be trusted

  • OS developers are engineers
    • Faster is better

16 of 21

Monolithic operating system

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

17 of 21

Alternative architectures: microkernel

  • Protection, but how much?
  • At cost of performance?
  • Windows NT (now vista) and Mac OS X have microkernel roots
  • More common on embedded systems, might see resurgence in the years to come

18 of 21

Alternative architecture: VMM

  • VMM is like microkernel with uncreative interface
  • But what about performance?
  • Today’s VMMs starting to resemble Microkernel

Hardware

VMM

OS

Identical interface

OS

OS

19 of 21

System call implementation

20 of 21

Unix system calls

  • File handle
    • Open, read, write
  • Process management
    • Fork, exec, wait
  • File namespace
    • Readdir, stat, unlink, link, rename

21 of 21

Project 1 hints

Use std::string for wgrep (and in general for string manipulation)

For wzip use hexdump to help debug

Reminder: use read/write/open/close

  • cout or printf are ok for error strings though

You have the full autograder test cases

  • We may turn on the autograder output
  • don’t forget to use -Wall -Werror though