1 of 24

ECS 150: History of OS and introduction to processes

Sam King

2 of 24

Administrative

  • Update on projects
    • Four in the first part of the class – one per week
      • Emphasis on processes, threads, and concurrency
      • Material for Midterm 1
    • 1-2 in the second half of the class
      • Emphasis on networking, distributed systems, file systems
      • Material for Midterm 2
  • First project out tomorrow
  • Late days for projects...

3 of 24

Administrative

  • Projects: submit individual projects, but it’s ok to work in groups
    • You need to write your own code, ok to talk with others about concepts
  • Spend some time on Friday to introduce the first project
  • No discussion this week, we’ll start it next week
  • For Zoom chat – the TAs will monitor or you can turn on your mic and ask

4 of 24

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

5 of 24

main() {

getInput();

computeResult();

printOutput();

}

getInput() {

cout();

cin();

}

computeResult() {

sqrt();

pow();

}

printOutput() {

cout();

}

Programs decompose into several rows

main

getInput

cout

6 of 24

  • 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

7 of 24

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

8 of 24

  • 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

9 of 24

Key abstractions

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

10 of 24

Examples!

  • Command line examples
  • Simple example about file descriptors

11 of 24

Administrative

Project 1 is out, due on Thursday April 8th

  • A note about figuring stuff out on your own

Using gradescope for grades

  • Both auto and manually graded portions

You don’t need to know command lines

  • You do need to know c/c++ and architecture

12 of 24

OS architectures

13 of 24

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

User mode

Kernel mode

14 of 24

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

Typical interactions w system

15 of 24

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

Shared libraries

16 of 24

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

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

17 of 24

A peek into Unix/Linux

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

Low-level (process switch)

18 of 24

OS architectures

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

  • OS developers are engineers
    • Faster is better

19 of 24

Monolithic operating system

Applications

Libraries (e.g., c runtime)

Portable OS Layer

Machine-dependent layer

20 of 24

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

21 of 24

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

22 of 24

System call implementation

23 of 24

Unix system calls

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

24 of 24

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