DOC PREVIEW
Rose-Hulman CSSE 332 - Operating Systems

This preview shows page 1-2-3-19-20-39-40-41 out of 41 pages.

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

Unformatted text preview:

Slide 1ProcessesTrace of ProcessSlide 4Process state modelsTwo-State Process ModelQueuing DiagramReason for Process CreationReasons for Process TerminationReasons for Process Termination5 Process StatesDiagram of Process StateExample for 3 ProcessesOS Control StructuresProcess Control Block (PCB)Process Control BlockSuspending ProcessesTwo Suspended StatesProcess Scheduling QueuesReady Queue, I/O Device QueuesProcess SchedulingSchedulersProcess SwitchingProcess SwitchingCPU Process SwitchMode switch vs Process switchModes of executionMode, Space and ContextExecution of the OSExecution within user processesUnix Process CreationUnix Process CreationUnix Process Creation (fork)Unix Process Creation (fork)exec Operationsexec Functionswaitpidwaitpid – pid parameterwaitpid – status parameterwaitpid – options parameterwaitpid optionsCSSE 332-01 Operating SystemsProcessesProcessesA process is a program in execution; process execution must progress in sequential fashion. Can be characterized by its trace.The OS interleaves the execution of several processes to maximize processor utilization A process requires resources, which are managed by the operating systemOS supports Inter-Process Communication (IPC) and user creation of processes2Trace of ProcessSequence of instructions that execute for a processDispatcher switches the processor from one process to another34Time slice ~= 1/10th of a secondProcess state modelsThe OS is responsible for interleaving the execution of the processes. It is important to understand the possible behaviors of all the processes and how to react to them. The behavior of processes is described by means of the process state model.5Two-State Process ModelProcess may be in one of two statesRunningNot-running6Queuing Diagram DispatcherProgram that assigns the processor to one process or anotherPrevents a single process from monopolizing processor time7ProcessorEnterQueueDispatchExitPause(a) Queuing diagramReason for Process Creation8Reasons for Process Termination9Reasons for Process Termination105 Process StatesAs a process executes, it changes stateNew: The process is being created.Running: Instructions are being executed.Waiting or blocked: The process is waiting for some event to occur.Ready: The process is waiting to be assigned to a process.Terminate or Exit: The process has finished execution.11Diagram of Process State12Example for 3 Processes13OS Control StructuresProcess Control Block (PCB)Information associated with each process.Process IDProcess stateProgram counter (PC)CPU registers (Context data)CPU scheduling information (Priority)Memory-management information (Memory pointer)Accounting information (Time, acct. #)I/O status information (requests, devices assigned)15Process Control BlockContains the process attributesCreated and manage by the operating systemAllows support for multiple processesProcess = Program code + Data + PCB16Suspending Processes17Two Suspended States18Process Scheduling QueuesJob queue – set of all processes in the system.Ready queue – set of all processes residing in main memory, ready and waiting to execute.Device queues – set of processes waiting for an I/O device.Process migration between the various queues.19Ready Queue, I/O Device Queues20Process Scheduling21SchedulersLong-term scheduler: job schedulerselects which processes should be brought into the ready queue.invoked infrequently (seconds, minutes)controls the degree of multiprogrammingMedium-term scheduler allocates memory for process.invoked periodically or as needed.Short-term scheduler: CPU schedulerselects which process should be executed next and allocates CPU.invoked frequently (ms)22Process SwitchingDefinitionThe activity that occurs when the OS kernel switches between processes in an effort to share the CPU among competing, runable processesActionsSave contents of hardware registers (PC, SP, ...)Load PC with location of resume pointLoad hardware registers with new context if full context switch23Process SwitchingProcess-switch time is overheadCPU utilization affected by quantum and process-switch timeQuantum: Time-slice (max CPU interval) given to a processTime dependent on hardware supportTypesVoluntary: Process blocksInvoluntary: End of time quantum or higher-priority, runable process gets control of CPU24CPU Process Switch25Mode switch vs Process switchWhen a mode switch occurs, the PCB of the process that was running is still marked Running and is not placed in the Blocked or Ready queue However, depending on what caused the mode switch, a process switch could follow26Modes of executionUser mode:Some parts of virtual address space can not be accessedSome instructions (e.g., memory management) can not be executedKernel mode:Can access kernel address spaceIs a fixed part of the virtual address space of every processSystem call puts user into kernel mode27Mode, Space and Context28Application(user space)System callsExceptions(user + system space)Xnot allowedInterrupts,System tasks(user space)Kernel ModeMore privilegesUser ModeProcess ContextKernel ContextSystem callInterrupt occursExecution of the OS29Execution within user processes30Unix Process CreationParents create children results in a tree of processesResource sharingParent and children share all resourcesChildren share subset of parent’s resourcesParent and child share no resourcesExecutionParent and children execute concurrentlyParent waits until children terminate31Unix Process CreationAddress spaceChild duplicate of parentChild has a program loaded into itUNIX examplesfork system call creates new processexec family of system calls used after a fork to replace the process’ memory space with a new program32Unix Process Creation (fork)Allocate new PID and proc structureInit child’s process control block (PCB)Copy parent’s registers to child’s hardware contextCopy parent’s process image to child’sMark child runnable and give to schedulerReturn PID = 0 to child Return child PID to parent33Unix Process Creation (fork)Effects of forkChild gets a copy of its parent’s memoryBUT changes made by child are not reflected in parentEXCEPT a child can affect the I/O state of parentFile descriptors


View Full Document

Rose-Hulman CSSE 332 - Operating Systems

Download Operating Systems
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 Systems 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 Systems 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?