INTRO TO OPERATING SYSTEMS
INTRO TO OPERATING SYSTEMS CS 333
Popular in Course
verified elite notetaker
Popular in ComputerScienence
This 47 page Class Notes was uploaded by Orrin Rutherford on Tuesday September 1, 2015. The Class Notes belongs to CS 333 at Portland State University taught by Jonathan Walpole in Fall. Since its upload, it has received 40 views. For similar materials see /class/168271/cs-333-portland-state-university in ComputerScienence at Portland State University.
Reviews for INTRO TO OPERATING SYSTEMS
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 09/01/15
CS 333 Introduction to Operating Systems Class 1 Introduction to OSrelated Hardware and Software Jonathan Walpole Computer Science Portland State University About the instructor u Instructor Jonathan Walpole z Professor at OGI 1989 2004 PSU 2004 z Director of Systems Software Lab at OGI z Research Interests Operating System Design Distributed Computing Systems Multimedia Computing and Networking 4 httpwwwcspdxeduwapoIe About CS 333 u Goals of the class z understand the basic concepts of operating systems 4 gain some practical experience so its not just all words a Expectations z reading assignments should be read before class z active participation in class discussions z no cheating z be nice to the instructor Grading u Exams MidTerm 39 25 70 z Final 25 u Coursework z project 30 u Quizzes z inclass quizzes and discussions 20 o Text books Modern Opera ring Sys remsquot The SPANK Sys remquot 2quotd EdiTion Har39r39y Por Ter A Tannenbaum MODERN OPERATING iASYSTEMS 23 SUIH ID DUNN Andrew S quotIchnbaum The project a You will read understand and write real operating system code a We will be using the SPANK system written by Harry Porter El AbOLI l39 4 CPU emulator assembler highlevel language operating system and debugging environment 4 Simple enough to understand in detailquot how everything works z Realistic enough to understand in detailquot how everything works z Runs on the departmental Sun machines Administrative a Class web site wwwcspdxeduwalpoIeclassc3333fall2005homehtm a Class mailing list z httpswebmaicecspdxedumaiImanlistinfocgic3333001 a Project 0 read the class web site join the class mailing list a Project 1 due next week See web site for project assignments Class 1 Introduction to OSr39elated Hardware and Software Overview a What is an Operating System a A review of OSrela red hardware What is an operating system u Operating system is a program that controls the execution of application programs and acts as an interface between the user of a computer and the computer hardwarequot z Narrow view Traditional computer with applications running on it eg PCs Workstations Servers z Broad view Anything that needs to manage resources eg router OS embedded devices pagers Two key 05 functions E Abstract Machine Hide details of the underlying hardware Provide quotcommonquot API to applications and services Simplifies application writing a Resource Manager 4 Controls accesses to quotsharedquot resources CPU memory disks network Allows for quotglobalquot policies to be implemented Why is abstraction important a Without 05s and abstract interfaces application writers program all device access directly load device command codes into device registers handle initialization recalibration sensing timing etc for physical devices understand physical characteristics and layout control motors interpret return codes etc a Applications suffer severe code bloat very complicated maintenance and upgrading 4 writing this code once and sharing it is how 05 began Providing abstraction via system calls Application System CPU Memory Video Card Network Hardware Monitor Disk Printer Providing abstraction via system calls Application System Calls readO openO writeO mkdirO killO Operating System Device Mgmt Process Mgmt File System Network Comm Protection Security CPU Memory Video Card Network Hardware Monitor Disk Printer 05 as a resource manager u Sharing resources among applications across space and time o scheduhng z allocation u Making efficient use of limited resources z improving utilization minimizing overhead z improving throughputgood put a Protecting applications from each other z enforcement of boundaries Problems an OS musT solve a Time sharing The CPU among applications a Space sharing The memory among applications a Space sharing The disk among users a Time sharing access To The disk a Time sharing access To The neTwor39k More problems an OS musT solve u ProTecTion z of applicaTions from each oTher z of user daTa from oTher users 4 of hardwaredevices z of The OS iTselfl u The 05 needs help from The hardware To accomplish These Tasks Overview a What is an Operating System a A review of OSrela red hardware Overview of computer system layers Barking ir raa Wash 335 mryea ien hi39mm39 Grimmer Q m m Eggmm if m f i SWU gram Rimming lame Mfmm mmm P ymim 39 egg11in pmymm wim H magmas Hardware CPU memory IO devices disk network Basic anatomy on a CPU 1 a Some key CPU Components z Program Counter PC holds memory address of next instruction z Instruction Register IR holds instruction currently being executed z Registers Reg 1n hold variables and temporary results 4 Arithmetic and Logic Unit ALU performs arithmetic functions and logic operations Basic anatomy on a CPU 2 a Some key CPU Components z Memory Address Register MAR con l39ains address of memory 10 be readwri H39en z Memory Da ra Register MDR con l39ains memory data read or To be written z S rack Poin rer SP holds memory address of a stack with a frame for each procedure39s local variables amp parame39l39ers z Processor S ra rus Word PSW contains The mode bi39l39 and various control bi39l39s Program execution u Instruction sets z different for different machines z all have load and store instructions for moving items between memory and registers z many instructions for comparing and combining values in registers and putting result in a register a FetchDecodeExecute cycle z fetch next instruction pointed to by PC z decode it to find its type and operands z execute it 4 repeat Fetchdecodeexecufe cycle CPU Memory PC IR MAR 1 ALU Fetchdecodeexecufe cycle Memory IMARI Reg 1 Reg 11 ALU While 1 Fetch instruction from memory Execute instruction Get other operands if necessary Store result Fetchdecodeexecute cycle Memory IMARI Reg 1 Reg 11 ALU While 1 Fetch instruction from memory Execute instruction Get other operands if necessary Store result Fetchdecodeexecute cycle Memory IMARI Reg 1 Reg 11 ALU While 1 Fetch instruction from memory Execute instruction Get other operands if necessary Store result Fetchdecodeexecufe cycle Memory IMARI Reg 1 Reg 11 ALU While 1 Fetch instruction from memory Execute instruction Get other operands if necessary Store result Fetchdecodeexecufe cycle Memory IMARI Reg 1 Reg 11 ALU While 1 Fetch instruction from memory Execute instruction Get other operands if necessary Store result Fetchdecodeexecute cycle Memory IMARI Reg 1 Reg 11 ALU While 1 Fetch instruction from memory Execute instruction Get other operands if necessary Store result The OS is jusT a program a How can The 05 cause application programs To run a How can applications programs cause The 05 To run a How can The OS swiTch The CPU To run a differenT applicaTion and laTer resume The firsT one a How can The OS mainTain conTrol a In whaT ways can applicaTion code Try To cheaT D And how can The OS sTop The cheaTing How can the OS invoke an application u The computer boots and begins running the 05 z fetchdecodeexecute OS instructions a 05 can request user input to identify an application to run z OS loads the address of the application39s starting instruction into the PC 4 CPU fetchesdecodesexecutes the application39s instructions How can applications invoke the 05 u Trap instruction changes PC to point to an 05 entry point instruction z application calls a library procedure that includes the appropriate trap instruction 4 fetchdecodeexecute cycle begins at a specified 05 entry point called a system call How can the 05 run a new application a To suspend execution of an application simply capture its memory state and processor state z copy values of all registers into a data structure and save it to memory 4 preserve the memory values of this application so it can be restarted later How can 05 guaranTee To regain conTrol a WhaT if a running application doesn39T make a sysTem call and hence hogs The CPU z Timer inTerrustl z OS musT regisTer a fuTure Timer inTerrupT before iT hands conTrol of The CPU over To an applicaTion a How can The OS avoid Trampling on The processor sTaTe iT wanTs To save z carefully wriTTen inTerrupT handlers What if the application tries to cheat a What stops the running application from disabling the future timer interrupt so that the 05 can not regain control z the mode bit in the PSW a Certain instructions can only be executed when the mode bit is set z manipulating timer interrupts z setting the mode bit What other ways are there to cheat a What stops the running application from modifying the OS z Memory protection z can only be set with mode bit set u The 05 must clear the mode bit before it hands control to an application z interrupts and trap instructions set the mode bit and transfer control to specific locations in the OS Why its not quite that simple u Pipelined CPUs u Superscalar CPUs u Multilevel memory hierarchies a Virtual memory a Complexity of devices and buses u Heterogeneity of hardware Pipelined CPUs Fetch Decode Execute unit unit unit Execu rion of current ins rr39uc rion performed in parallel wi rh decode of nex r instruction and fe rch of The one offer Tha r Superscalar39 CPUs Fetch unit Decode unit Execute unit Fetch unit Holding V Decode unit buffer Execute unit Execute unit What does this mean for the OS u Pipelined CPUs z more complexity in capturing state of a running application 4 more expensive to suspend and resume applications a Superscalar CPUs z even more complexity in capturing state of a running application z even more expensive to suspend and resume applications a More details but fundamentally the same task a The SPANK CPU is not pipelined or superscalar The memory hierarchy El El D D D ZGHz processor 9 05 ns Datainst cache 9 05ns 10 ns this is where the CPU looks rstl Main memory 9 60 ns 512 MB IGB Magnetic disk 9 10 ms 160 Gbytes Tape 9 Longer than you want less than magnetic disk 64 kB 1MB Figure 114 The Memory Hierarchy Terminology review metric units ler 39 mm 1 gamma 1 arm 39 The me rr39ic prefixes The memory hierarchy a ZGHz processor 9 05 as for access 10 a few 10s of registers a Datainst cache 9 05ns 10 ns th5 is where fhe CPU looks rst a Main memory 9 60 as 512 MB 163 a Magne39l39ic disk 9 10 ms 160 Gby l39es a Tape 9 Longer wai39l39 l39han you want costs less l39han magnetic disk 64 kB 1MB Figure 114 The Memory Hierarchy Who manages the memory hierarchy a Movement of data from main memory to cache is under hardware control cache lines loaded on demand automatically replacement policy fixed by hardware a Movement of data from cache to main memory can be affected by OS instructions for flushing the cache can be used to maintain consistency of main memory a Movement of data among lower levels of the memory hierarchy is under direct control of the OS virtual memory page faults file system calls OS implications of a memory hierarchy a How do you keep the contents of memory consistent across layers of the hierarchy a How do you allocate space at layers of the memory hierarchy quotfairlyquot across different applications a How do you hide the latency of the slower subsystems Main memory yikes Disk Tape a How do you protect one application39s area of memory from other applications a How do you relocate an application in memory Quiz How does The OS solve These problems 4 Time sharing The CPU among applicaTions Space sharing The memory among applications z Space sharing The disk among users z Time shar39ing access To The disk 4 Time shar39ing access To The neTwor39k z Pr39oTecTion of applicaTions from each oTher39 z Pr39oTecTion of user39 daTa from oTher39 user39s z Pr39oTecTion of hardware devices z Pr39oTecTion of The OS iTself What to do before next class a Reading for today39s class pages 170 a Reading for next week39s class pages 71100 u Assignment 0 r39ead class web page and join class email list a Start project 1 Introduction to SPANK