UT CS 372 - OS Structure, Processes & Process Management

Unformatted text preview:

1OS Structure,Processes & Process Management2RecapOS functionsÿ Coordinatorv Protectionv Communicationv Resource managementÿ Service providerv File system, device handler, …Questions:ÿ How can the OS perform these functions?ÿ How is an OS invoked?ÿ What is the structure of the OS?3An Operating System in ActionCPU loads boot program from ROM (e.g. BIOS in PC’s)Boot program:ÿ Examines/checks machine configuration (number of CPU’s, howmuch memory, number & type of hardware devices, etc.)ÿ Builds a configuration structure describing the hardwareÿ Loads the operating system, and gives it the configurationstructureOperating system initialization:ÿ Initialize kernel data structuresÿ Initialize the state of all hardware devicesÿ Creates a number of processes to start operation (e.g. getty inUNIX, the Windowing system in NT, e.g.)4O.S. in Action (Cont’d)After basic processes have started, the OS runs userprograms, if available, otherwise enters the idle loopIn the idle loop:ÿ OS executes an infinite loop (UNIX)ÿ OS performs some system management & profilingÿ OS halts the processor and enter in low-power mode(notebooks)OS wakes up on:ÿ Interrupts from hardware devicesÿ Exceptions from user programsÿ System calls from user programsTwo modes of executionÿ User mode: Restricted execution mode (applications)ÿ Supervisor mode: Unrestricted access to everything (OS)5Control Flow in an OSOperating System ModulesIdleLoopFrom bootInitializationRTIInterruptSystem callmain()ExceptionSupervisor ModeSupervisor ModeReturn to user modeReturn to user mode6On InterruptsHardware calls the operating system at a pre-specifiedlocationOperating system saves state of the user programOperating system identifies the device and cause ofinterruptResponds to the interruptOperating system restores state of the user program (ifapplicable) or some other user programExecute an RTI instruction to return to the user programUser program continues exactly at the same point it wasinterrupted.Key Fact: None of this is visible to the user program7On ExceptionsHardware calls the operating system at a pre-specifiedlocationOperating system identifies the cause of the exception (e.g.divide by 0)If user program has exception handling specified, then OSadjust the user program state so that it calls its handlerExecute an RTI instruction to return to the user programIf user program did not have a specified handler, then OSkills it and runs some other user program, as availableKey Fact: Effects of exceptions are visible to user programsand cause abnormal execution flow8On System CallsUser program executes a trap instruction (system call)Hardware calls the operating system at a pre-specifiedlocationOperating system identifies the required service andparameters (e.g. open(filename, O_RDONLY))Operating system executes the required serviceOperating system sets a register to contain the result ofcallExecute an RTI instruction to return to the user programUser program receives the result and continuesKey Fact: To the user program, it appears as a function callexecuted under program control9Operating System(process/device/memory management, file systems, interprocess communication, …) Operating System(process/device/memory management, file systems, interprocess communication, …) Operating System TodayHigh-level software architectureMemoryInstruction Execution & Interrupt ProcessingUser ApplicationsUser ApplicationsWindowSystemCommandInterpreterI/O Devices“Middleware”“Middleware”10Operating System StructuresMonolithic OS (e.g., Unix) Micro-kernel OS (e.g.,Mach, Exokernel, …)Memory ManagementMemory ManagementCPU SchedulingCPU SchedulingProcess ManagementProcess ManagementHardwareHardwareNetwork SupportNetwork SupportSecuritySecurityFile SystemFile SystemCommand InterpreterCommand InterpreterDevice ManagementDevice ManagementNetwork SupportNetwork SupportMemoryMgmt.MemoryMgmt.WindowServerWindowServerFileServerFileServer...... HardwareHardwareCPUSchedulingCPUSchedulingDevice DriversDevice DriversInterruptHandlerInterruptHandlerBoot andInit.Boot andInit.Message PassingMessage Passing……APIAPI11SummaryAn OS is just a program:ÿ It has a main() function, which gets called only once (duringboot)ÿ Like any program, it consumes resources (such as memory), cando silly things (like generating an exception), etc.But it is a very strange program:ÿ It is “entered” from different locations in response to externaleventsÿ It does not have a single thread of control, it can be invokedsimultaneously by two different events (e.g. system call & aninterrupt)ÿ It is not supposed to terminateÿ It can execute any instruction in the machine12Processes and Process ManagementWhat is a Program? How to run a Program?A program consists of code and dataOn running a program, the loader:ÿ reads and interprets the executable fileÿ sets up the process’s memory to contain the code & data fromexecutableÿ pushes “argc”, “argv” on the stackÿ sets the CPU registers properly & calls “__start()”Program starts running at _start()_start(args) {ret = main(args);exit(ret)}we say “process” is now running, and no longer think of “program”When main() returns, OS calls “exit()” which destroys theprocess and returns all resources13So, What is a Process?A process is an abstraction that supports running programsA process is the basic unit of execution in an operatingsystemDifferent processes may run several instances of the sameprogramAt a minimum, process execution requires followingresources:ÿ Memory to contain the program code and dataÿ A set of CPU registers to support execution14Anatomy of a ProcessCodeHeaderInitialized dataExecutable FileCodeInitialized dataHeapStackDLL’smapped segmentsProcess’s address spacePCStack Pointer RegistersPIDUIDPriorityList of open files…PCStack Pointer RegistersPIDUIDPriorityList of open files…Process ControlBlock15Process Life CycleProcesses are always either executing, waiting toexecute or waiting for an event to occurRunningRunningReadyReadyWaitingWaitingStartStartDoneDone16Process ContextsExample: MultiprogrammingOperating SystemOperating System“System Software”“System Software”User Program 1User Program 1User Program 2User Program 2User Program 2User Program 2User Program nUser Program n...Program 1 Program 2OSI/ODevicek:


View Full Document

UT CS 372 - OS Structure, Processes & Process Management

Documents in this Course
MapReduce

MapReduce

17 pages

Processes

Processes

19 pages

MapReduce

MapReduce

17 pages

Load more
Download OS Structure, Processes & Process Management
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 OS Structure, Processes & Process Management 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 OS Structure, Processes & Process Management 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?