Review History of OS Why Study CS162 Operating Systems and Systems Programming Lecture 3 To understand how user needs and hardware constraints influenced and will influence operating systems Several Distinct Phases Hardware Expensive Humans Cheap Eniac Multics Concurrency Processes Threads and Address Spaces 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 September 2nd 2009 Prof John Kubiatowicz http inst eecs berkeley edu cs162 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 years 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 2 Review Implementation Issues How is the OS implemented Review Migration of OS Concepts and Features 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 hardware 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 3 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 4 Goals for Today Concurrency How do we provide multiprogramming What are Processes How are they related to Threads and Address Spaces 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 Note Some slides and or pictures in the following are adapted from slides 2005 Silberschatz Galvin and Gagne Gagne Many slides generated from my lecture notes by Kubiatowicz 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 5 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 9 2 09 The Basic Problem of Concurrency 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 Kubiatowicz CS162 UCB Fall 2009 Lec 3 6 Recall 61C What happens during execution The basic problem of concurrency involves resources 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 7 Addr 232 1 R0 R31 F0 F30 PC Data1 Fetch Data0 Exec Inst237 Inst236 Inst5 Execution sequence Inst4 Fetch Instruction at PC Inst3 Decode Inst2 Execute possibly using registers Inst1 Write results to registers mem Inst0 9 2 09 PC Next Instruction PC Repeat Kubiatowicz CS162 UCB Fall 2009 PC PC PC PC Addr 0 Lec 3 8 How can we give the illusion of multiple processors CPU1 CPU2 Properties of this simple multiprogramming technique All virtual CPUs share same non CPU resources CPU3 CPU1 Shared Memory CPU2 CPU3 CPU1 I O devices the same Memory the same CPU2 Time Assume a single processor How do we provide the illusion of multiple processors 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 Multiplex in time Each virtual CPU needs a structure to hold Program Counter PC Stack Pointer SP Registers Integer Floating point others This unprotected model common in How switch from one CPU to the next Embedded applications Windows 3 1 Machintosh switch only with yield Windows 95 ME switch with both yield and timer 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 things 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 9 9 2 09 Modern Technique SMT Hyperthreading Project Signup Watch Group Section Assignment Link 4 5 members to a group Everyone in group must be able to actually attend same section Exploit natural properties of superscalar processors to provide illusion of multiple processors Higher utilization of processor resources The sections assigned to you by Telebears are temporary Only submit once per group Everyone in group must have logged into their cs162 xx accounts once before you register the group Make sure that you select at least 2 potential sections Due Tomorrow Thursday 9 3 by 11 59pm Can schedule each thread as if were separate CPU However not linear speedup If have multiprocessor should schedule each processor first Original technique called Simultaneous Multithreading See http www cs washington edu research smt Alpha SPARC Pentium 4 Hyperthreading Power 5 Kubiatowicz CS162 UCB Fall 2009 Lec 3 10 Administriva Time for Project Signup Hardware technique 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 11 Sections Watch for section assignments next Monday Tuesday Attend new sections next week Section Time TA Location 101 Tu 10 00A 11 00A Gunho Lee 6 Evans 102 Tu 11 00A 12 00P Gunho Lee 4 Evans 105 New Tu 1 00P 2 00P 4 Evans Alex Smolen 4 Evans 103 Tu 2 00P 3 00P Jingtao Wang 104 Tu 3 00P 4 00P 75 Evans Jingtao Wang 9 2 09 Kubiatowicz CS162 UCB Fall 2009 Lec 3 12 Administrivia 2 How to protect threads from one another Cs162 xx accounts Make sure you got an account form If you haven t logged in yet you need to do so Need three important things 1 Protection of memory Every task does not have access to all memory Email addresses 2 Protection of I O devices We need an email address from you If you haven t given us one already you should get prompted when you log in again or type register Hopefully we fixed bug that kept asking you to run the register program again Every task does not have access to every device 3 Protection of Access to Processor Preemptive switching from task to task Use of timer Must not be possible to disable timer
View Full Document
Unlocking...