{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture02 - CS140 Winter 2008 Handout#2 Today's adventure...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS140 - Winter 2008 - Handout #2 CS 140: OS hacking Lecture 2: threads & processes Mendel Rosenblum Winter ‘08 Today’s adventure What are processes, threads? What are they for? How do they work? Threads vs processes? Readings: 6 th ed: Silberschatz/Galvin: Ch 4 (skip 4.{5,6}), Ch 5. 7 th ed: Silberschatz/Galvin: Ch 3 (skip 3.{4-6}), Ch 4. Hundreds of things going on in system How to make simple? Separate each in isolated process. OS deals with one thing at a time, they just deal with OS *THE* universal trick for managing complexity: decomposition (“reductionism”) Why processes? Simplicity gcc emacs nfsd lpr ls www emacs nfsd lpr ls www OS OS I/O parallelism: Overlap execution: make 1 CPU into many (Real parallelism: > 1 CPU (multiprocessing)) Completion time: B’s completion time = 100s (A + B) So overlap Why processes? Speed emacs (Wait for input) (Wait for input) gcc A B A B 20 s 80 s Completion time for B? A? 10 s Processes in the real world Processes, parallelism fact of life much longer than OSes have been around Companies use parallelism for more throughput: 1 worker = 100 widgets? hire 100 to make 10,000. Can you always partition work to speed up job? Ideal: N-fold speedup Reality: bottlenecks + coordination overhead Example: CS140 group project (More abstractly: easy to increase throughput, reducing latency more difficult) What is a thread? In theory: Turing machine tape (state), tape head (position) In practice: What’s needed to run code on CPU “execution stream in an execution context” Execution stream: sequential seq. of instructions CPU execution context (1 thread) State: stack, heap, registers Position: program counter register OS execution context (n threads): identity + open file descriptors, page table, … add r1, r2, r3 sub r2, r3, r10 st r2, 0(r1)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon