ebook img

Introduction to Operating System Design and Implementation: the OSP 2 Approach PDF

177 Pages·2007·2.537 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Introduction to Operating System Design and Implementation: the OSP 2 Approach

Undergraduate Topics in Computer Science Undergraduate Topics in Computer Science (UTiCS) delivers high-quality instructional content for undergraduatesstudyinginallareasofcomputingandinformationscience.Fromcorefoundationaland theoreticalmaterialtofinal-yeartopicsandapplications,UTiCSbookstakeafresh,concise,andmodern approachandareidealforself-studyorforaone-ortwo-semestercourse.Thetextsareallauthoredby establishedexpertsintheirfields,reviewedbyaninternationaladvisoryboard,andcontainnumerous examplesandproblems.Manyincludefullyworkedsolutions. Alsointhisseries IainD.Craig Object-OrientedProgrammingLanguages:Interpretation 978-1-84628-773-2 MaxBramer PrinciplesofDataMining 978-1-84628-765-7 HanneRiisNielsonandFlemmingNielson SemanticswithApplications:AnAppetizer 978-1-84628-691-9 Michael Kifer and Scott A. Smolka Introduction to Operating System Design and Implementation The OSP 2 Approach MichaelKifer,PhD ScottA.Smolka,PhD StateUniversityofNewYork StateUniversityofNewYork atStonyBrook,NY,USA atStonyBrook,NY,USA Serieseditor IanMackie ÉcolePolytechnique,FranceandKing’sCollegeLondon,UK Advisoryboard SamsonAbramsky,UniversityofOxford,UK ChrisHankin,ImperialCollegeLondon,UK DexterKozen,CornellUniversity,USA AndrewPitts,UniversityofCambridge,UK HanneRiisNielson,TechnicalUniversityofDenmark,Denmark StevenSkiena,StonyBrookUniversity,USA IainStewart,UniversityofDurham,UK DavidZhang,TheHongKongPolytechnicUniversity,HongKong BritishLibraryCataloguinginPublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary LibraryofCongressControlNumber:2007926598 UndergraduateTopicsinComputerScienceISSN1863-7310 ISBN978-1-84628-842-5 e-ISBN978-1-84628-843-2 Printedonacid-freepaper c Springer-VerlagLondonLimited2007 ⃝ Apartfromanyfairdealingforthepurposesofresearchorprivatestudy,orcriticismorreview,as permittedundertheCopyright,DesignsandPatentsAct1988,thispublicationmayonlybereproduced, storedortransmitted,inanyformorbyanymeans,withthepriorpermissioninwritingofthe publishers,orinthecaseofreprographicreproductioninaccordancewiththetermsoflicencesissued bytheCopyrightLicensingAgency.Enquiriesconcerningreproductionoutsidethosetermsshouldbe senttothepublishers. Theuseofregisterednames,trademarks,etc.inthispublicationdoesnotimply,evenintheabsenceofa specificstatement,thatsuchnamesareexemptfromtherelevantlawsandregulationsandthereforefree forgeneraluse. Thepublishermakesnorepresentation,expressorimplied,withregardtotheaccuracyofthe informationcontainedinthisbookandcannotacceptanylegalresponsibilityorliabilityforanyerrors oromissionsthatmaybemade. 987654321 SpringerScience+BusinessMedia springer.com Contents Preface ......................................................... ix 1. Organization of 2 ..................................... 1 OSP 1.1 Chapter Objective........................................ 1 1.2 Operating System Basics .................................. 1 1.3 2 Organization ..................................... 6 OSP 1.4 Simulated Hardware in 2 ............................. 8 OSP 1.5 Utilities ................................................. 11 1.6 2 Events ........................................... 16 OSP 1.7 2 Daemons ......................................... 18 OSP 1.8 Compiling and Running Projects ........................... 19 1.9 General Rules of Engagement .............................. 24 1.9.1 A Day in the Life of an 2 Thread................ 25 OSP 1.9.2 Convention for Calling Student Methods .............. 26 1.9.3 Static vs. Instance Methods.......................... 28 1.9.4 Obfuscation of Method and Class Names .............. 28 1.9.5 Possible Hanging After Errors........................ 29 1.9.6 Possible Exceptions After the End of Execution ........ 29 1.9.7 General Advice: How to Figure it Out ................ 29 1.10 System Log, Snapshots, and Statistics....................... 30 1.11 Debugging............................................... 31 1.12 Project Submission ....................................... 35 2. Putting it All Together: An Example Session with 2 .. 39 OSP 2.1 Chapter Objective........................................ 39 2.2 Overview of Thread Management in 2 ................. 39 OSP vi Introduction to OperatingSystemDesign and Implementation:The 2 Approach OSP 2.3 The Student Method do resume().......................... 40 2.4 Step 1: Compiling and Running the Project.................. 41 2.5 Step 2: Examining the OSP.log File ........................ 42 2.6 Step 3: Introducing an Error into do resume()............... 43 3. Tasks: Management of Tasks (a.k.a. Processes) ............. 45 3.1 Chapter Objective........................................ 45 3.2 Conceptual Background ................................... 45 3.3 Class TaskCB ............................................ 46 3.4 Methods Exported by the Tasks Package ................... 53 4. Threads: Management and Scheduling of Threads .......... 57 4.1 Chapter Objective........................................ 57 4.2 Overview of Threads...................................... 57 4.3 The Class ThreadCB ...................................... 61 4.4 The Class TimerInterruptHandler......................... 71 4.5 Methods Exported by the Threads Package................. 72 5. Memory: Virtual Memory Management..................... 75 5.1 Chapter Objective........................................ 75 5.2 Overview of Memory Management.......................... 75 5.3 Class FrameTableEntry................................... 83 5.4 Class PageTableEntry .................................... 86 5.5 Class PageTable ......................................... 90 5.6 Class MMU................................................ 91 5.7 Class PageFaultHandler.................................. 95 5.8 Methods Exported by Package Memory ....................100 6. Devices: Scheduling of Disk Requests.......................103 6.1 Chapter Objective........................................103 6.2 Overview of I/O Handling .................................103 6.3 Class IORB...............................................106 6.4 Class Device ............................................109 6.5 Class DiskInterruptHandler..............................114 6.6 Methods Exported by Package Devices.....................117 7. FileSys: The File System ...................................119 7.1 Chapter Objective........................................119 7.2 File System Design Objectives .............................119 7.3 Overview of the 2 File System ........................121 OSP 7.4 Class MountTable ........................................123 7.5 Class INode..............................................127 Contents vii 7.6 Class DirectoryEntry ....................................129 7.7 Class OpenFile ..........................................131 7.8 Class FileSys ...........................................136 7.9 Methods Exported by the FileSys Package..................141 8. Ports: Interprocess Communication ........................143 8.1 Chapter Objective........................................143 8.2 Interprocess Communication in 2 ......................143 OSP 8.3 The MessageClass .......................................144 8.4 The PortCB Class ........................................146 8.5 Methods Exported by PackagePorts.......................151 9. Resources: Resource Management..........................153 9.1 Chapter Objective........................................153 9.2 Overview of Resource Management .........................153 9.3 Overview of Resource Management in 2 ................155 OSP 9.4 Class ResourceTable .....................................156 9.5 Class RRB................................................157 9.6 Class ResourceCB ........................................160 9.7 Methods Exported by the Resources Package...............166 Index...........................................................167 Preface 2 is bothanimplementationofamodernoperatingsystem,andaflexible OSP environment for generating implementation projects appropriate for an intro- ductory course in operating system design. It is intended to complement the use of an introductory textbook on operating systems and contains enough projects for up to three semesters. These projects expose students to many essential features of operating systems, while at the same time isolating them from low-level machine-dependent concerns. Thus, even in one semester, stu- dents can learn about page replacement strategies in virtual memory manage- ment, cpu scheduling strategies, disk seek time optimization, and other issues in operating system design. 2 is written in the Java programminglanguage and students program OSP their 2 projectsinJavaaswell.Thereforeasprerequisitesforusing 2, OSP OSP students are expected to have solid Java programming skills; be well-versed in object-oriented programming concepts such as classes, objects, methods, and inheritance; to have taken an undergraduate Computer Science course in data structures;andtohaveworkingknowledgeofaJavaprogrammingenvironment, i.e., javac,java,text editing, etc. 2 is the successorto the original OSP OSP software, which was released in 1990 and programmedin C. 2 consists of a number of modules, each of which performs a basic OSP operating systems service, such as device scheduling, cpu scheduling, inter- rupt handling, file management, memory management, process management, resource management, and interprocess communication. Projects can be orga- nized in any desired order so as to progress in a manner consistent with the lecture material. The 2 distribution comes with a reference Java imple- OSP mentation of each module, which is provided to the course instructor. Each 2 project has a well-defined API (application programming in- OSP terface), that the student must implement in order to successfully complete x Introduction toOperating SystemDesign andImplementation:The 2 Approach OSP the project. Thus, among other things, 2 teaches students to work with OSP “open” environments where programming must be conducted to satisfy con- cretesets ofprojectrequirementsandwhere APIsmustbe usedtointerface to other subsystems. Each 2 project consists of a “partialloadmodule” of standard 2 OSP OSP modules to which the students link their implementation of the assigned mod- ules.Theresultisanewandcompleteoperatingsystem,partiallyimplemented by the student. Additionally, each project includes one or more “*.java” files, which contain class and method headings for each of the assigned modules. These files serve as templates in which the student is to fill in the code for the requiredmethods. This ensures a consistent interface to 2 and eliminates OSP much of the routine typing, both by the instructor and by the student. The heart of 2 is a simulator that gives the illusion of a computer OSP systemwithadynamicallyevolvingcollectionofuserprocessestobemultipro- grammed. All the other modules of 2 are built to respond appropriately OSP to the simulator-generated events that drive the operating system. The simu- lator “understands” its interactionwith the other modules in that it can often detect an erroneous response by a module to a simulated event. In such cases, the simulator will gracefully terminate execution of the program by delivering a meaningful error message to the user, indicating where the error might be found. This facility serves both as a debugging tool for the student and as teachingtoolforthe instructor,asitensuresthatstudentprogramsacceptable to the simulatorarevirtuallybug-free.(Verificationbythe simulatordoesnot, ofcourse,replacetheneedtoexaminestudentprogramstoensurethattheyare properly designed and acceptable from a software engineering point of view.) The difficulty of the job streams generated by the simulator can be dy- namically adjusted by manipulating the simulation parameters. This yields a simple and effective way of testing the quality of student programs. There are alsofacilities thatallowstudents to debug theirprograms,including adetailed system log of events and various hooks into the system that allow student- provided methods to be called when an 2 warning or error is detected. OSP Also, a graphical user interface (GUI) is available that provides a convenient way for students and instructors to enter simulation parameters and to view various statistics concerning the execution of 2. OSP The underlying model in 2 is not a clone of any specific operating OSP system. Rather it is an abstraction of the common features of several systems (although a bias towards Unix and the Mach operating systems can be seen, at times). Moreover, the 2 modules were designed to hide a number of OSP low-levelconcerns,yetstillencompassthe mostsalientaspectsoftheirreal-life counterparts in modern systems. Their implementation is well-suited as the project component of an introductory course in operating systems.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.