lecture03 - CS140 - Winter 2008 - Handout #3 Past and...

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

View Full Document Right Arrow Icon
CS140 - Winter 2008 - Handout #3 1 CS 140: Operating Systems Lecture 3: Concurrency Mendel Rosenblum ± Past: isolated processes modularize system share resources speed ± Today: safe non-isolated processes Processes share state (computer, files, memory). Concurrent access = bugs. » Example: single lane road, two approaching cars ± Readings: Silbershatz/Galvin: 6 th Ed - ch 7; 7 th Ed – ch 6 gcc Past and Present hardware OS www ls vi Multiple processes, one world: safe? ± No. Bugs if one process writes state that could be simultaneously read/written by another. emacs writes out file while gcc compiling it. Result? Hard to predict, except that its probably not going to be correct (or repeatable: have fun). Always dangerous? (No. More later.) But often enough that you better think carefully. ± When safe? Isolated processes “isolated” = shares no state with any other process doesn’t really exist: share file system, memory, … new old emacs gcc Isolated vs non-isolated processes ± isolated: no shared data between processes If P produces result x, then running any other set of independent processes P’, P’’, … wouldn’t change it. Scheduling independence: any order = same result Consider: internet, lots of independent machines. If don’t share state, doesn’t matter what other people do. ± Non-isolated: share state Result can be influenced by what other processes running Scheduling can alter results Big problem: non-deterministic. Same inputs != same result. Makes debugging very very hard. new old emacs gcc new emacs gcc Why share? Two core reasons ± Cost: buy m, amortize cost by letting n share (n > m) One computer, many jobs; one road, many cars; this classroom, many other classes. ± Information: need results from other processes Gives speed: parallel threads working on same state Gives modularity(?!): ability to share state lets us split tasks into isolated processes (gcc, emacs) and communicate just what is necessary Sharing information hugely important. Consider impact of new ways to share information (print, telephone, internet, www, human voice) emacs gcc c.c Example: two threads, one counter ± Assume a popular web server. Uses multiple threads (on multiple processors) to speed things up. ± Simple shared state error: each thread increments a
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/24/2008 for the course CS 140 taught by Professor Rosenblum during the Winter '08 term at Stanford.

Page1 / 4

lecture03 - CS140 - Winter 2008 - Handout #3 Past and...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online