DOC PREVIEW
Princeton COS 318 - Operating System Structures

This preview shows page 1-2-14-15-30-31 out of 31 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 31 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 31 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 31 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 31 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 31 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 31 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 31 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Operating System StructuresGedankenexperimentMechanicsNext Reading AssignmentAbout Quiz 0Quiz 0 QuestionsQuestion 4 (22 out of 46)Question 5 (29 out of 46)A Typical Computer from a Hardware Point of ViewA Typical Computer SystemTypical Unix OS StructureSlide 12Slide 13Slide 14Slide 15Another Look: Unix “Onion”What’s An Application?OS Service ExamplesProcessor ManagementMemory Managementx86 Architecture Registersx86 MemoryI/O Device ManagementWindow SystemsFile SystemBootstrappingSystem BootROM BIOS startup program (1)ROM BIOS startup program (2)ROM BIOS startup program (3)Ways to Develop An Operating SystemCOS318 Lec 2 1Operating System StructuresVivek PaiPrinceton UniversityCOS318 Lec 2 2GedankenexperimentWhat does this program do?static void Loop(void){static char *startAddr;char local;printf(“diff is %d\n”, startAddr – (&local));startAddr = &local;Loop( );}int main(int argc, char *argv[ ]){Loop( );}COS318 Lec 2 3MechanicsHave you:Subscribed to pu.cs.318?Sent me mail with your details?–Hey, it was an assignment after all…Sent me a picture of yourself?COS318 Lec 2 4Next Reading AssignmentSections 1.6-2.1 inclusiveKeep up with what’s on home pageI’ll try to remember to remind youComing up: x86 assembly for Proj 2COS318 Lec 2 5About Quiz 0It didn’t count, so don’t worry“Scores” are5: 9 people4: 14 people3: 14 people2: 8 people1: 1 personCOS318 Lec 2 6Quiz 0 QuestionsRegister – everyone correct?Stack – data structure: last-in, first-outStack frame – on procedure calls, formal parameters, local variables, return address all get pushed onto stackCOS318 Lec 2 7Question 4 (22 out of 46)int *p = 0;printf(“val is %d\n”, *p);Type of p is “pointer to integer”.Value of p is zero.Deref of p is getting value at location 0, being read as an integer.Should cause an error on any sane system.COS318 Lec 2 8Question 5 (29 out of 46)Func( ) {int *result;CallSomeFunc(result);}Note: value of result can not changeWhat can change is data at location pointed to by resultTo change value of result, you have to pass address of resultNormally, you declare result as a non-pointer, and pass in its address by &resultCOS318 Lec 2 9A Typical Computer from a Hardware Point of ViewCPUChipsetMemoryI/O busCPU. . .NetworkCOS318 Lec 2 10A Typical Computer SystemOperating System SoftwarePrograms and dataMemoryCPUCPU...OSAppsDataNetworkCOS318 Lec 2 11Typical Unix OS StructureApplicationPortable OS LayerLibrariesMachine-dependent layerUser space/levelKernel space/levelCOS318 Lec 2 12Typical Unix OS StructureApplicationPortable OS LayerLibrariesMachine-dependent layerWritten by programmerCompiled by programmerUses function callsCOS318 Lec 2 13Typical Unix OS StructureApplicationPortable OS LayerLibrariesMachine-dependent layerWritten by elvesProvided pre-compiledDefined in headersInput to linker (compiler)Invoked like functionsMay be “resolved” when program is loadedCOS318 Lec 2 14Typical Unix OS StructureApplicationPortable OS LayerLibrariesMachine-dependent layer“Guts” of system callsAll “high-level” codeCOS318 Lec 2 15Typical Unix OS StructureApplicationPortable OS LayerLibrariesMachine-dependent layerBootstrapSystem initializationInterrupt and exception I/O device driverMemory managementKernel/user mode switchingProcessor managementCOS318 Lec 2 16Another Look: Unix “Onion”ApplicationsOS ServiceDeviceDriverHardwareUser and KernelboundaryCOS318 Lec 2 17What’s An Application?Four parts (“segments”)Code/Text – instructionsData – initialized global variablesStackHeapWhat’s a stack and heap?COS318 Lec 2 18OS Service ExamplesExamples that are not provided at user level–System calls: file open, close, read and write–Control the CPU so that users won’t stuck by runningwhile ( 1 ) ;–Protection: •Keep user programs from crashing OS•Keep user programs from crashing each otherExamples that can be provided at user level–Read time of the day–Protected user level stuffCOS318 Lec 2 19Processor ManagementGoals–Overlap between I/O and computation–Time sharing–Multiple CPU allocationsIssues–Do not waste CPU resources–Synchronization and mutual exclusion–Fairness and deadlock freeCPU I/O CPUCPUI/OCPUCPUI/OCPUCPUCPUCOS318 Lec 2 20Memory ManagementGoals–Support programs to run–Allocation and management–Transfers from and to secondary storageIssues–Efficiency & convenience–Fairness–ProtectionTape 100MxDisk 10MxMemory 200xL2 10xRegisterCOS318 Lec 2 21x86 Architecture RegistersGeneral-purpose registersSegment registersEFLAGS register EIP (Instruction Pointer register)EAXEBXECXEDXEBPESIEDIESP310015CSDSSSESFSGSAXBXCXDX16-bit 32-bitDISIBPSPALAHBLCLDLBHCHDH8 715COS318 Lec 2 22x86 Memory0232-1Byte order is little endian 3108 716 15...24 23Byte 4Byte 0Byte 5Byte 1Byte 2Byte 6Byte 3Byte 7COS318 Lec 2 23I/O Device ManagementGoals–Interactions between devices and applications–Ability to plug in new devicesIssues–Efficiency–Fairness–Protection and sharingUser 1 User n. . .Library supportI/OdeviceI/Odevice. . .Driver DriverCOS318 Lec 2 24Window SystemsAll in the kernel (Windows)–Pros: efficient?–Cons: difficult to develop new servicesAll at user level–Pros: easy to develop new apps–Cons: protectionSplit between user and kernel (Unix)–Kernel: display driver and mouse driver–User: the restCOS318 Lec 2 25File SystemA typical file system –Open a file with authentication–Read/write data in files–Close a fileCan the services be moved to user level?User 1 User n. . .File system servicesFile File. . .COS318 Lec 2 26BootstrappingPower up a computerProcessor reset–Set to known state–Jump to ROM codeLoad in the boot loader from stable storageJump to the boot loaderLoad the rest of the operating systemInitialize and runBootloaderOSsector 1OSsector 2OSsector n...BootloaderCOS318 Lec 2 27System BootPower on (processor waits until Power Good Signal)Processor jumps on a PC (“Intel Inside”) to address FFFF0h•1M= 1,048,576= 220 =FFFFFh+1 •FFFFFh=FFFF0h+16 is the end of the (first 1MB of) system memory•The original PC using Intel 8088 had 20 address lines :-)(FFFFFFF0h) is a JMP instruction to the ROM BIOS startup programMaps to FFFFFFF0h= 232-16COS318 Lec 2 28ROM BIOS startup program (1)POST (Power-On Self-Test)•If pass then AX:=0; DH:=5 (586: Pentium);•Stop booting if fatal errors, and


View Full Document

Princeton COS 318 - Operating System Structures

Documents in this Course
Overview

Overview

25 pages

Deadlocks

Deadlocks

25 pages

lectute 2

lectute 2

28 pages

Lecturel

Lecturel

24 pages

Real mode

Real mode

49 pages

Lecture 2

Lecture 2

54 pages

lecture 5

lecture 5

27 pages

Load more
Download Operating System Structures
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 Operating System Structures 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 Operating System Structures 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?