DOC PREVIEW
Berkeley COMPSCI 162 - Lecture 3 Concurrency: Processes, Threads, and Address Spaces

This preview shows page 1-2-16-17-18-34-35 out of 35 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 35 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS162 Operating Systems and Systems Programming Lecture 3 Concurrency: Processes, Threads, and Address SpacesReview: History of OSReview: Migration of OS Concepts and FeaturesReview: Implementation Issues (How is the OS implemented?)Goals for TodayConcurrencyThe Basic Problem of ConcurrencyRecall (61C): What happens during execution?How can we give the illusion of multiple processors?Properties of this simple multiprogramming techniqueModern Technique: SMT/HyperthreadingAdministriva: Second Try for Project SignupAdministrivia (2)How to protect threads from one another?Recall: Program’s Address SpaceProviding Illusion of Separate Address Space: Load new Translation Map on SwitchTraditional UNIX ProcessHow do we multiplex processes?CPU Switch From Process to ProcessDiagram of Process StateProcess SchedulingWhat does it take to create a process?Process =? ProgramMultiple Processes Collaborate on a TaskShared Memory CommunicationInter-process Communication (IPC)Modern “Lightweight” Process with ThreadsSingle and Multithreaded ProcessesExamples of multithreaded programsExamples of multithreaded programs (con’t)Thread StateExecution Stack ExampleClassificationExample: Implementation Java OSSummaryCS162Operating Systems andSystems ProgrammingLecture 3Concurrency:Processes, Threads, and Address SpacesSeptember 8, 2008Prof. John Kubiatowiczhttp://inst.eecs.berkeley.edu/~cs162Lec 3.29/8/07 Kubiatowicz CS162 ©UCB Fall 2008Review: History of OS•Why Study?–To understand how user needs and hardware constraints influenced (and will influence) operating systems•Several Distinct Phases:–Hardware Expensive, Humans Cheap »Eniac, … Multics–Hardware Cheaper, Humans Expensive »PCs, Workstations, Rise of GUIs–Hardware Really Cheap, Humans Really Expensive »Ubiquitous devices, Widespread networking•Rapid Change in Hardware Leads to changing OS–Batch  Multiprogramming  Timeshare  Graphical UI  Ubiquitous Devices  Cyberspace/Metaverse/??–Gradual Migration of Features into Smaller Machines•Situation today is much like the late 60s–Small OS: 100K lines/Large: 10M lines (5M browser!)–100-1000 people-yearsLec 3.39/8/07 Kubiatowicz CS162 ©UCB Fall 2008Review: Migration of OS Concepts and FeaturesLec 3.49/8/07 Kubiatowicz CS162 ©UCB Fall 2008Review: Implementation Issues(How is the OS implemented?)•Policy vs. Mechanism–Policy: What do you want to do?–Mechanism: How are you going to do it?–Should be separated, since policies change •Algorithms used–Linear, Tree-based, Log Structured, etc…•Event models used–threads vs event loops•Backward compatability issues–Very important for Windows 2000/XP/Vista/…–POSIX tries to help here•System generation/configuration–How to make generic OS fit on specific hardwareLec 3.59/8/07 Kubiatowicz CS162 ©UCB Fall 2008Goals for Today•How do we provide multiprogramming?•What are Processes?•How are they related to Threads and Address Spaces?Note: Some slides and/or pictures in the following areadapted from slides ©2005 Silberschatz, Galvin, and Gagne Note: Some slides and/or pictures in the following areadapted from slides ©2005 Silberschatz, Galvin, and Gagne. Many slides generated from my lecture notes by Kubiatowicz.Lec 3.69/8/07 Kubiatowicz CS162 ©UCB Fall 2008Concurrency•“Thread” of execution–Independent Fetch/Decode/Execute loop–Operating in some Address space•Uniprogramming: one thread at a time–MS/DOS, early Macintosh, Batch processing–Easier for operating system builder–Get rid concurrency by defining it away–Does this make sense for personal computers?•Multiprogramming: more than one thread at a time–Multics, UNIX/Linux, OS/2, Windows NT/2000/XP, Mac OS X–Often called “multitasking”, but multitasking has other meanings (talk about this later)•ManyCore  Multiprogramming, right?Lec 3.79/8/07 Kubiatowicz CS162 ©UCB Fall 2008The Basic Problem of Concurrency•The basic problem of concurrency involves resources:–Hardware: single CPU, single DRAM, single I/O devices–Multiprogramming API: users think they have exclusive access to shared resources•OS Has to coordinate all activity–Multiple users, I/O interrupts, …–How can it keep all these things straight?•Basic Idea: Use Virtual Machine abstraction–Decompose hard problem into simpler ones–Abstract the notion of an executing program–Then, worry about multiplexing these abstract machines•Dijkstra did this for the “THE system”–Few thousand lines vs 1 million lines in OS 360 (1K bugs)Lec 3.89/8/07 Kubiatowicz CS162 ©UCB Fall 2008FetchExecR0…R31F0…F30PC…Data1Data0Inst237Inst236…Inst5Inst4Inst3Inst2Inst1Inst0Addr 0Addr 232-1Recall (61C): What happens during execution?•Execution sequence:–Fetch Instruction at PC –Decode–Execute (possibly using registers)–Write results to registers/mem–PC = Next Instruction(PC)–Repeat PCPCPCPCLec 3.99/8/07 Kubiatowicz CS162 ©UCB Fall 2008How can we give the illusion of multiple processors?CPU3CPU2CPU1Shared Memory•Assume a single processor. How do we provide the illusion of multiple processors?–Multiplex in time!•Each virtual “CPU” needs a structure to hold:–Program Counter (PC), Stack Pointer (SP)–Registers (Integer, Floating point, others…?)•How switch from one CPU to the next?–Save PC, SP, and registers in current state block–Load PC, SP, and registers from new state block•What triggers switch?–Timer, voluntary yield, I/O, other thingsCPU1 CPU2 CPU3 CPU1 CPU2TimeLec 3.109/8/07 Kubiatowicz CS162 ©UCB Fall 2008Properties of this simple multiprogramming technique•All virtual CPUs share same non-CPU resources–I/O devices the same–Memory the same•Consequence of sharing:–Each thread can access the data of every other thread (good for sharing, bad for protection)–Threads can share instructions(good for sharing, bad for protection)–Can threads overwrite OS functions? •This (unprotected) model common in:–Embedded applications–Windows 3.1/Machintosh (switch only with yield)–Windows 95—ME? (switch with both yield and timer)Lec 3.119/8/07 Kubiatowicz CS162 ©UCB Fall 2008Modern Technique: SMT/Hyperthreading•Hardware technique –Exploit natural propertiesof superscalar processorsto provide illusion of multiple processors–Higher utilization of processor resources•Can schedule each threadas if were separate CPU–However, not linearspeedup!–If have multiprocessor,should


View Full Document

Berkeley COMPSCI 162 - Lecture 3 Concurrency: Processes, Threads, and Address Spaces

Documents in this Course
Lecture 1

Lecture 1

12 pages

Nachos

Nachos

41 pages

Security

Security

39 pages

Load more
Download Lecture 3 Concurrency: Processes, Threads, and Address Spaces
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 3 Concurrency: Processes, Threads, and Address Spaces and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 3 Concurrency: Processes, Threads, and Address Spaces 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?