Hệ điều hành - Chapter 3: Process description and control

What is a process? Process states which characterize the behaviour of processes. Data structures used to manage processes. Ways in which the OS uses these data structures to control process execution.

ppt56 trang | Chia sẻ: huyhoang44 | Lượt xem: 524 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Hệ điều hành - Chapter 3: Process description and control, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Chapter 3 Process Description and ControlWhat is a process? Process states which characterize the behaviour of processes. Data structures used to manage processes. Ways in which the OS uses these data structures to control process execution. Requirements of an Operating SystemFundamental Task: Process ManagementThe Operating System mustInterleave the execution of multiple processesAllocate resources to processesProtect the resources of each process from other processesEnable processes to share and exchange informationEnable synchronization among processes.What is a “process”?A program in executionAn instance of a program running on a computerThe entity that can be assigned to and executed on a processorA unit of activity characterized by the execution of a sequence of instructions, a current state, and an associated set of system resourcesProcess ElementsA process is comprised of:Program code (possibly shared)A set of data associated with the codeA number of attributes describing the state of the processProcess ElementsWhile the process is running, it has a number of attributes includingIdentifierStatePriorityProgram counterMemory pointersContext dataI/O status informationAccounting informationTrace of the ProcessThe behavior of an individual process is shown by listing the sequence of instructions that are executedThis list is called a TraceDispatcher is a small program which switches the processor from one process to anotherProcess ExecutionConsider three processes being executedAll are in memory (plus the dispatcher)Trace from the Process point of view:The 4th instruction of Process B invokes an I/O operation.Trace from Processor’s point of viewTimeoutI/OTimeoutTimeoutTime slice: 6 instruction cyclesRoadmapWhat is a process? Process states which characterize the behaviour of processes. Data structures used to manage processes. Ways in which the OS uses these data structures to control process execution. Two-State Process ModelTo control processes, we need to describe their behavior Process may be in one of two statesRunningNot-runningQueuing DiagramEtc processes moved by the dispatcher of the OS to the CPU then back to the queue until the task is competedProcesses that are not running must be kept in some sort of queue, waiting their turn to execute.Process Birth and Death Common ReasonsCreationTermination New batch jobNormal CompletionInteractive LoginMemory unavailableCreated by OS to provide a serviceProtection errorSpawned by existing processOperator or OS InterventionSee tables 3.1 and 3.2 for moreProcess CreationThe OS builds a data structure to manage the processTraditionally, the OS creates all processesBut it can be useful to let a running process create another, e.g., a server process may generate a new process for each requestThis action is called process spawningParent Process is the original, creating processChild Process is the new processProcess TerminationThere must be some way that a process can indicate completion.This indication may be:A HALT instruction for termination in a batch job A user action (e.g. log off, quitting an application)A fault or errorParent process terminatingFive-State Process ModelProcesses may be blocked (e.g., waiting for an I/O operation)Using Two QueuesMultiple Blocked QueuesSuspended ProcessesProcessor is faster than I/O, so all processes could be waiting for I/OSwap these processes to disk to free up more memory and use processor on more processesBlocked state becomes suspend state when swapped to diskOne Suspend StateTwo Suspend StatesWhen the event of a suspended (and blocked) process occurs, the process is not blocked and is potentially available for execution.Process Suspension Common Reasons ReasonCommentSwappingThe OS needs to release sufficient main memory to bring in a process that is ready to execute.Other OS ReasonOS suspects process of causing a problem.Interactive User Requeste.g. debugging or in connection with the use of a resource.TimingA process may be executed periodically (e.g., an accounting or system monitoring process) and may be suspended while waiting for the next time.Parent Process RequestA parent process may wish to suspend execution of a descendent to examine or modify the suspended process, or to coordinate the activity of various descendants.Table 3.3 Reasons for Process SuspensionRoadmapWhat is a process?Process states which characterize the behaviour of processes. Data structures used to manage processes. Ways in which the OS uses these data structures to control process execution. Processes and ResourcesOS can be thought of an entity that manages the use of system resources by processes.Operating System Control StructuresFor the OS to manage processes and resources, it must have information about the current status of each process and resource. Tables are constructed for each entity the operating system managesOS Control TablesMemory TablesMemory tables are used to keep track of both main and secondary memory. Must include this information:Allocation of main memory to processesAllocation of secondary memory to processesProtection attributes for access to shared memory regionsInformation needed to manage virtual memoryI/O TablesUsed by the OS to manage the I/O devices and channels of the computer.The OS needs to knowWhether the I/O device is available or assignedThe status of I/O operationThe location in main memory being used as the source or destination of the I/O transferFile TablesThese tables provide information about:Existence of filesLocation on secondary memoryCurrent statusother attributesSometimes this information is maintained by a file management systemProcess TablesTo manage processes, the OS needs to know details of the processes Current stateProcess IDLocation in memoryetcProcess image is the collection of program, data, stack, and attributesProcess AttributesThe attributes are stored in a data structure called a process control block (PCB)It contains sufficient information so that it is possible to interrupt a running process and later resume its execution.Process AttributesWe can group the PCB information into three general categories:Process identificationProcessor state informationProcess control informationProcess IdentificationEach process is assigned a unique numeric identifier.Many of the other tables controlled by the OS may use process identifiers to cross-reference process tablesProcessor State InformationThis consists of the contents of processor registers. User-visible registersControl and status registersStack pointersProgram status word (PSW) contains condition codes and other status informationProcess Control InformationThis is the additional information needed by the OS to control and coordinate the various active processes.Process state, priority, identity of the waiting event etc.See table 3.5 for scope of informationStructure of Process Images in Virtual MemoryRole of the Process Control BlockPCB is the most important data structure in an OSOS needs information about a process which is stored in PCB.Most OS modules, such as scheduling, resource allocation, and interrupt processing read and/or modify PCBs.The set of PCBs defines the state of the OS.RoadmapWhat is a process?Process states which characterize the behaviour of processes. Data structures used to manage processes. Ways in which the OS uses these data structures to control process execution. Modes of ExecutionMost processors support at least two modes of execution to protect OS from interference by user programsUser modeLess-privileged modeUser programs typically execute in this modeSystem modeMore-privileged modeProcess CreationOnce the OS decides to create a new process, it:Assigns a unique process identifierAllocates space for the processInitializes process control blockSets up appropriate linkagesCreates or expands other data structuresSwitching ProcessesSeveral design issues are raised regarding process switchingWhat events trigger a process switch? What must the OS do to the various data structures under its control to achieve a process switch?When to switch processesMechanismCauseUseInterruptExternal to the execution of the current instructionReaction to an asynchronousexternal eventTrapAssociated with the execution of the current instructionHandling of an error or anexception conditionSupervisor callExplicit requestCall to an operating systemfunctionTable 3.8 Mechanisms for Interrupting the Execution of a ProcessA process switch may occur any time that OS has gained control from the currently running process. Possible events giving OS control are: Change of Process State The steps in a process switch are:Save context of processor including program counter and other registersUpdate the process control block of the process that is currently in the Running stateMove process control block to appropriate queue – ready; blocked; ready/suspendChange of Process State contSelect another process for executionUpdate the process control block of the process selectedUpdate memory-management data structuresRestore context of the selected processMode Switching The occurrence of an interrupt does not necessarily mean a process switch.It is possible that, after the interrupt handler has executed, the currently running process will resume execution.In that case, only need to save / restore the processor state information in hardware.Is the OS a Process?If the OS is just a collection of programs and if it is executed by the processor just like any other program, is the OS a process?If so, how is it controlled?Who (what) controls it?These questions have inspired a number of design approachesNon-process KernelExecute kernel outside of any processOS has its own region of memory and system stackThe concept of process is considered to apply only to user programsOperating system code is executed as a separate entity that operates in privileged modeExecution Within User ProcessesExecute Within User ProcessesOS is a collection of routines called by the user to perform various functionsNo need for Process Switch to run OS routine, only Mode SwitchProcess-based Operating SystemProcess-based operating systemImplement the OS as a collection of system processSecurity IssuesAn OS associates a set of privileges with each process.These privileges dictate what resources the process may accessHighest level being administrator, supervisor, or root access.A key security issue in the design of any OS is to prevent anything (user or process) from gaining unauthorized privileges on the systemSystem access threatsIntruders (hackers, crackers)gain access to a systemacquire protected information Masqueraderunauthorised outsiderMisfeasorlegitimate insider performing unauthorised accessClandestine user outside or insider seizing supervisory control of the systemSystem access threatsMalicious software (malware)destroy files and data in main memorybypass controls to gain privileged accessprovide a means for intruders to bypass access controlparasitic (to a host program) e.g., virusesself-contained (independent), e.g., wormsCountermeasures: Intrusion DetectionIntrusion detection systems (IDS) monitors and analyzes system events for suspicious activity to detect human intruder and malicious software behaviour.IDS typically compriseSensors for collecting data, e.g., log filesAnalyzers for determining if an intrusion has occurredUser Interface for viewing output and controlling behavior of the systemCountermeasures: AuthenticationTwo Stages:Identification (provide a claimed identity)Verification (establish validity of the claim)Four Factors:Something the individual knowsSomething the individual possessesSomething the individual is (static biometrics)Something the individual does (dynamic biometrics)Countermeasures: Access ControlA policy governing access to resourcesA security administrator maintains an authorization database that specifies what type of access to which resources is allowed for which usersThe access control function consults this to determine whether to grant access.Countermeasures: FirewallsFirewalls protect a local system from network-based security threats while at the same time afford access to the outside world.Traditionally, a firewall is a dedicated computer that:interfaces with computers outside a network has special security precautions built into it to protect sensitive files on computers within the network.

Các file đính kèm theo tài liệu này:

  • pptchap3_5743.ppt