1 / 44

Chapter 6: Process Management

Chapter 6: Process Management. Prof. Steven A. Demurjian, Sr. † Computer Science & Engineering Department The University of Connecticut 191 Auditorium Road, Box U-155 Storrs, CT 06269-3155. steve@engr.uconn.edu http://www.engr.uconn.edu/~steve (860) 486 - 4818.

ila-love
Download Presentation

Chapter 6: Process Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6: Process Management Prof. Steven A. Demurjian, Sr. † Computer Science & Engineering Department The University of Connecticut 191 Auditorium Road, Box U-155 Storrs, CT 06269-3155 steve@engr.uconn.edu http://www.engr.uconn.edu/~steve (860) 486 - 4818 † These slides have been modified from a set of originals by Dr. Gary Nutt.

  2. Purpose of this Chapter • Process Management Combination of Scheduling, Synchronization, and Deadlock Avoidance • Process Management from System Programmer’s Perspective • Process Management Activity … • Address Space Creation and Utilization • Resource Allocation and Management • Process Creation - Parent/Child Processes • Goal: Answer the Following: • What are Key Requirements of PM? • What are Fundamental Actions of PM? • What is Interplay with other OS Functions?

  3. What is a Process? • A Process is Composed of … • Static Program for Process Behavior • Static and Dynamic Data for Process that Drives Operation and Produces Results • When is Data Static? Examples? • What is Data Dynamic? Examples? • Static and Dynamic Resources Needed to Support the Execution of Process • Dynamic Status Record of Process’ Execution Progress and State • What OS Functions Play Significant Role in Process Execution?

  4. Process Manager Overview Program Process Abstract Computing Environment Deadlock Process Description File Manager Protection Synchronization Device Manager Memory Manager Resource Manager Resource Manager Scheduler Resource Manager Devices Memory CPU Other H/W

  5. What Impacts Process Management? • Assumptions Regarding our Process Discussion • Timeshared/Multi-Programmed OS • CPU Shared Among Multiple Processes • Scheduler Switches CPU Among Processes • Process has Many States • Idle - Doing Nothing by Choice • Blocked - Needs a Resource to Continue • Running - Current Job CPU is Executing • Wait - Ready to Execute/CPU will be Back • Focus on … • Process Descriptors and Their Management • Process Execution and Control • Process Utilization of Resources

  6. Process Management • Core Topics • Representing the Essential Characteristics of a Process with the Process Descriptor • Identifying What “Things” Can Be Referenced within the Address Space • Allocating Resources • Creating/Destroying Processes • Ancillary Topics • Scheduling the CPU (Chapter 7) • Synchronization Mechanisms (Chapters 8-9) • Deadlock (Chapter 10)

  7. Process Descriptor Conceptual View • Two Purposes • Manage OS Process Abstraction • Distinguish Processes to Avoid Interference • Process Descriptor is Data Structure for the Process • Register Values for Each Process • Logical State (Idle, Blocked, Run, Wait) • Type & Location of Resources Held • List of Resources Needed for Execution • Security Keys • Memory State and Stack Pointer • Why is Each Descriptor Component Needed? • Note: Limit on Active Processes/OS and /User

  8. Process Descriptor Detailed View (see Table 6.1) • Internal Process Name • State • Owner: Who Started Process • Parent Process & List of Child Process Descriptor: Processes can Spawn Other Processes • List of Reusable Resources • List of Consumable Resources • List of File Descriptors (Open Files) • Message Queue • Protection Domain (Security) • CPU Status & General Register Content: Copies of Registers that are Needed to Restart Process

  9. Process Descriptor Execution • Block Structured Languages Require Processes to Manage Multiple Scopes • Recall, Scope is Defined for the Set of Variables that Occupy a “Block” in a Program • Function or “{ … }” in C • Begin/End in Pascal, Ada, etc. • Variables within Scope Part of “Frame” Saved on Process’s Runtime Stack • Enter Scope - New Frame • Leave Scope - Delete Frame • Does Anyone Know What a “Frame” Refers to? ACTIVATION RECORD!!!

  10. What are Activation Records? • Storage Organization for Program Execution • Code Referenced by PC • Global/Local Variables • Stack Contains • Set of Activation Records • All Active Procedures and Functions • Heap for Dynamic Memory Allocation Code Static Data Stack Heap

  11. To the Calling Procedure Passed in to Procedure To Act. Record of Caller Referenced Non-Local Data Needed to Restart Caller Local Variables for Scope Compiler Generated A General Activation Record Returned Value Actual Parameters Optional Control Link Optional Access Link Saved Machine Status Local Data Temporaries

  12. An Activation Record in C • Actual Parameters Supplied by Caller • Needed to Restart Caller • Local Variables for Scope • If Callee Calls Another Procedure/Function Etc. Incoming Param 2 Incoming Param 1 Saved State Info Local Variables Temporary Storage Outgoing Parameters

  13. Activation Record andProcess Descriptors • How Do the Two Concepts Relate to Each Other? • Do Following Issues for Activation Play a Role in Process Management? • Recursion and Activation Records • Sharing of Local Data Across Invocations • Access to Non-Local Data by Procedures • Passing Procedures/Functions as Parameters • Returning Procedures/Functions as Results • Dynamic Memory Allocation

  14. NT Organization Process Process T T Process T T T T Libraries T T T Subsystem Subsystem Subsystem User Super- visor I/O Subsystem NT Executive NT Kernel Hardware Abstraction Layer Main Memory Processor(s) Devices

  15. NT Process Descriptor User Space Supervisor Space NT Executive ETHREAD EPROCESS NT Kernel KPROCESS (PCB) KTHREAD

  16. NT Process Descriptor • Kernel Process Object Including: • Pointer to the Page Directory • Kernel & User Time • Process Base Priority • Process State • List of the Kernel Thread Descriptors That Are Using This Process

  17. NT Process Descriptor (Continued) • Parent Identification • Exit Status • Creation and Termination Times • Memory Status • Security Information • Executable Image • Process Priority Class Used by the Thread Scheduler • A List of Handles Used by this Process • A Pointer to Win32-Specific Information

  18. Transition from Program to Process • Recall a Program as Collection of Software Modules • Each Module “Compiled” Object Module • Object Modules “Linked” for Executable • What Must be Considered for this to Occur? • What are “Object” Modules Created From? • How Does “Executable” Track Memory Needed for Instructions/Data?’ • How is a “Program” Started? Stopped? Restarted? • What Underlies “Runtime” Environment? THE ADDRESS SPACE!!!

  19. The Address Space • Definition: Address Space are Locations Utilized by Process to Reference • Primary Memory Locations • OS Services and Resources • Address Space is NOT JUST Primary Memory • Also Refers to other Critical Services Offered by OS • For Example, • Mailboxes to Information • Abstractions to Files, Disks, etc. • “Anything” that Program Needs that Can be “Addressed” During Compilation and Lining

  20. The Address Space Primary Memory Process Mailboxes Address Space Files System Services Other Objects

  21. Defining the Address Space • Some Parts are Influenced by Programming Language • Static in C/C++ for Compile Allocation • malloc/new for Dynamic Allocation • Some Parts are Built into the Environment • Files • System Services • Some Parts are Imported at Runtime • Mailboxes • Network Connections • Memory Address Block is Created at Compile Time

  22. The Compile Time Component “.o” Files from Modules Across Prog. Languages Unix: C, Fortran, Ada, C++, ... “a.out” Can Combine “.o” Regardless of Origins Source Modules Translator Relocatable Modules Absolute Program Primary Memory Link Editor Executable Program Loader

  23. Consistency and Address Management • Scheduling and Resource Management Requires • Ability to Start, Suspend, Restart Process • Decision Based on • Timesharing of CPU • Priorities of “Executing” Processes • Memory Manager May Need to … • Remove Executable from Primary Memory • Save Executable to Secondary Memory • De-allocate Primary Memory for Use by Another Process • Load and Active “New” Process • Repeat Above Steps to Timeshare

  24. Where are Consistency Problems? • Consider “Executing Process” • Currently Loaded in Primary Memory • Copy Located in Secondary Memory • What Happens When Local Variable in Executing Primary Memory Copy is Changed? • Is Secondary Storage Automatically Updated? • Who Does Update? Process or Memory Manager? • What Further Complicates this Problem?

  25. The Memory Hierarchy R1 R2 Rn • Can “Same” Datum Have Inconsistent Values? • Modify Ri and Not M(P) • Modify Ri/MP and Not M(S) • What if Process is Swapped Out? • How Does Data Remain Consistent? Are Levels of MemoryHierarchy Missing? PC M(R) IR CACHE Primary Memory M(P) What is Direction of Access? Controller Buffers Secondary Memory M(S)

  26. Aside: Two Concepts from CSE230 • Finite State Machines (FSMs) • States and Transitions Among States • Transitions Based on Input • Initial and Final State • Petri Nets • Places, Tokens, and Transitions • To Fire “Transition” Consume Tokens in Place for All Inputs and Generate Tokens for All Outputs • FSMs Utilized to Capture Process States • Tokens of PNs Represent Resources that are Consumed and Produced

  27. Managing Resources • Resources (Memory, Files, Mouse, etc.) Must be Allocated for Use by Process • Differentiate Between • Reusable Resources: Can be Allocated to Another Process After Completion • What are Some Examples? • Consumable Resource: Not Reusable, Hence, Consumed During Process Execution • What is Primary Example? • Resource Manager • Controls Reusable/Renewable Resources • Allocates to Processes as Needed • Multiple Copies/Resource Possible

  28. Resource Manager Requests Resource Manager Process Allocate Release Allocate Release Process Release Process Allocate Resource Pool Why is Queuing Utilized for Requests?

  29. Role of Queuing in Resource Management • Queuing Employed to Avoid • Starvation of Process Requests • Deadlock of Processes • For Example, Easiest Way for Deadlock • Order Resources Provided by OS: A, B, C, … • Processes Must Request Resources in Order • Scheme Prevents Following: • Process One Holds A and Wants B • Process Two Holds B and Wants A • Process Two Must Request A First, and Hence will Not be Given Access to B without Holding A • More in Chapter 10

  30. Process State Diagram (Version 1) • FSM in Practice • Remember … • Each Process in Contention with Other Processes for CPU • Running Implies Process has CPU • Blocked Implies Waiting for Something • Ready Means Will Run on Next Turn • How is Timesharing Represented? • Can Model Multiple Processes with FSM? Request Done Running Request Schedule Start Allocate Ready Blocked

  31. Creating and Managing Processes • Differentiate Between • Software Engineering Initiated Behavior • Shared Memory Architectures • Message Passing Solutions • OS Command Level Initiation of Process • Non-Sharable Address Space • OS Provided Paradigms that Promote the Spawning of Processes (or Threads) • How are Processes/Threads Spawned? • What Does Process Manager Need to Know to Manage Multiple Active Processes? • Program Level Initiation of Process • Sharable Address Space

  32. Creating a Process • We have Seen UNIX Fork & Exec in Chapter 2 • Derived from General FORK, JOIN, & QUIT FORK(label): Create another process in the same address space beginning execution at instruction label. Continue execution with next statement. QUIT():The process terminates itself. JOIN(count): Stop forked process and recombine. Must disable interrupts to prevent any disruption of merging. disableInterrupts(); count--; if(count > 0) QUIT(); enableInterrupts();

  33. Example of Concurrently Executing Processes procA() { while(TRUE) { <compute section A1>; update(x); <compute section A2>; retrieve(y); } } procB() { while(TRUE) { retrieve(x); <compute section B1>; update(y); <compute section B2>; } } x Process A Process B y • Two Processes Share Variables x and y • Interleave Execution to Insure • Process A Doesn’t Modify y Until B Updates • Process B Doesn’t Modify x Until A Updates

  34. Example of Concurrently Executing Processes • Consider Code Shown • Labels Differentiate Segments of Code Involving Modifications to X and Y • What are Interleaved Steps of Processing? L0: count = 2; <compute section A1>; update(x); FORK(L2); <compute section A2>; L1: JOIN(count); retrieve(y); goto L0; L2: retrieve(x); <compute section B1>; update(y); FORK(L3); goto L1; L3: <compute section B2> QUIT();

  35. Multiple Processes in MBDSWhat is MBDS? • MBDS is Multi-Process, Multi-Computer, Parallel Database System • MBDS Composed of … • Host for Issuing User Requests • Controller to Interact with Host (and User) • One or More Backend Database Processors • Goals of MBDS • Suppose Request Takes 4 Minutes with One Backend • Improve Response Time by Increasing Backends • Two Backends - Request 2+ Minutes • Four Backends - Request 1+ Minutes

  36. Multiple Processes in MBDSWhat is MBDS Architecture? Backend Database Processor Backend Database Processor Database Controller Host/User Backend Database Processor

  37. Multiple Processes in MBDSWhat are MBDS Processes? Request Preparation Post Processing Database Controller Put Msg. Get Msg. Get Msg. Put Msg. Directory Management Record Processing Backend Database Processor Concurrency Control Disk I/O

  38. Multiple Processes in MBDSWhat are MBDS Messages? No. Type SRC DST 1 New Request Host ReqP 2 Results of Request PoPr Host 3 Number of Reqs in Transaction ReqP PoPr 4 Aggregate Operators (Sum, etc.) ReqP PoPr 6 Parsed Request to Backends ReqP DM 12 Backend Aggregate Operator Results RecP PoPr 15 Ids for Accessing Database Indexes DM DMs 16 Request and Disk Addresses DM RecP 21 Ids for Accessing Database Records DM CC 22 Locks Obtained: Okay to Execute CC RecP 23 Request ID of Finished Request RecP CC

  39. Multiple Processes in MBDSSample Processing of Retrieve Request B3 A1 K12 Request Preparation Post Processing C4 K12 D6 Put Msg. Get Msg. F15 From Other Backend E15 To Backend(s) Get Msg. Put Msg. K12 D6,F15 E15 Record Processing I16 Directory Management J23 H22 G21 Concurrency Control Disk I/O

  40. Reflections and Suppositions • How Would you “Redesign MBDS” Under Different Assumptions? • Shared Memory? • Java RMI? • JINI? • Fork/Join to Spawn Children? • Threading? • Ignore Actual Details of MBDS and Focus on Architecture! • Excellent Exam Question that Brings Together SW Engineering Skills and OS Understanding!!

  41. Revisiting Thread Concepts • In Unix, Spawning Child Allocates “Own” Address Space • In NT, Threads Execute within Address Space of Parent as Independent Unit of Computation • Scheduler Can Timeshare CPU with Threads • Threads Share Resources of “Parent” • Threads Divide Work Associated with Process • User Threads: Scheduled and Managed by Software Developer for his/her Code • Kernel Threads: Managed by OS

  42. Process Hierarchies • Parent-Child Relationship May Be Significant • Parent Typically Initiates Child • Parent Controls Child’s Execution • Parent Can Spawn Multiple Children Initial Process System Process System Process Child Process Child Process

  43. Process State Diagram (Version 2) Request Done Running Yield Suspend Request Schedule Suspend Start Ready-Active Activate Ready-Suspended Allocate Allocate Suspend Blocked-Suspended Blocked-Active Activate

  44. Concluding Remarks/Looking Ahead • Review of Process Management • Program vs. Process vs. Compilation • Impact of Memory Hierarchy on Processes • Process Creation and Management • Activation Records and Multi-Process Software • Interesting Exercise 4 in Section 6.7 • Recall Version 1 of Process State Diagram • Change Diagram to Not Block Unless Resource is Unavailable • Looking Ahead to … • Scheduling (Chapter 7) • Synchronization (Chapters 8 & 9)

More Related