Operating Systems: A Modern Perspective, Chapter 6

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Slide 3-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 3 3 Operating System Organization.
Threads, SMP, and Microkernels Chapter 4. Process Resource ownership - process is allocated a virtual address space to hold the process image Scheduling/execution-
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Implementing Processes, Threads, and Resources.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Process Management. External View of the OS Hardware fork() CreateProcess() CreateThread() close() CloseHandle() sleep() semctl() signal() SetWaitableTimer()
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
Chapter 6 Implementing Processes, Threads, and Resources.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Threads, Thread management & Resource Management.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Mid Term review CSC345.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Implementing Processes, Threads, and Resources 6.
© 2004, D. J. Foreman 1 Implementing Processes and Threads.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Threads, Thread management & Resource Management.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
2 Processor(s)Main MemoryDevices Process, Thread & Resource Manager Memory Manager Device Manager File Manager.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program.
What is a Process ? A program in execution.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Introduction to Operating Systems Concepts
Introduction to Kernel
Processes and threads.
Process concept.
Process Management Process Concept Why only the global variables?
Protection of System Resources
Implementing Processes and Threads
System Structure and Process Model
System Structure and Process Model
Structure of Processes
System Structure B. Ramamurthy.
Threads, SMP, and Microkernels
Outline Announcements Process Management – continued
Process & its States Lecture 5.
Mid Term review CSC345.
Process Description and Control
Lecture Topics: 11/1 General Operating System Concepts Processes
Process Description and Control
Lecture 4- Threads, SMP, and Microkernels
Threads Chapter 4.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Process Description and Control
Operating Systems: A Modern Perspective, Chapter 3
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Operating Systems: A Modern Perspective, Chapter 6
Implementing Processes and Threads
Implementing Processes, Threads, and Resources
Processes in Unix and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control
Process Description and Control in Unix
Outline Process Management Process manager Hardware process
Process Description and Control in Unix
Implementing Processes and Threads
Implementing Processes, Threads, and Resources
Presentation transcript:

Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Implementing Processes, Threads, and Resources Operating Systems: A Modern Perspective, Chapter 6

Implementing the Process Abstraction Pi Address Space Pi CPU Pi Executable Memory Pj Address Space Pj CPU Pj Executable Memory Pk Address Space … Pk CPU Pk Executable Memory OS interface OS Address Space CPU ALU Machine Executable Memory Control Unit … Operating Systems: A Modern Perspective, Chapter 6

External View of the Process Manager Application Program Device Mgr Process Mgr Memory Mgr File Mgr Windows CreateThread() CreateProcess() CloseHandle() WaitForSingleObject() fork() wait() exec() Device Mgr Process Mgr Memory Mgr File Mgr UNIX Hardware Operating Systems: A Modern Perspective, Chapter 6

Process Manager Responsibilities Define & implement the essential characteristics of a process and thread Algorithms to define the behavior Data structures to preserve the state of the execution Define what “things” threads in the process can reference – the address space (most of the “things” are memory locations) Manage the resources used by the processes/threads Tools to create/destroy/manipulate processes & threads Tools to time-multiplex the CPU – Scheduling the (Chapter 7) Tools to allow threads to synchronization the operation with one another (Chapters 8-9) Mechanisms to handle deadlock (Chapter 10) Mechanisms to handle protection (Chapter 14) Operating Systems: A Modern Perspective, Chapter 6

Modern Processes and Threads Thrdj in Pi Thrdk in Pi … Pi CPU … … OS interface … Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Processes &Threads Stack State Map State Stack Map Address Space Program Static data Resources Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 The Address Space Executable Memory Address Space Address Binding Process Files Other objects Operating Systems: A Modern Perspective, Chapter 6

Building the Address Space Some parts are built into the environment Files System services Some parts are imported at runtime Mailboxes Network connections Memory addresses are created at compile (and run) time Operating Systems: A Modern Perspective, Chapter 6

Tracing the Hardware Process Machine is Powered up Bootstap Process Manager Interrupt Handler P1 P,2 Pn Loader Load the kernel Initialization Execute a thread … Schedule Hardware process progress Service an interrupt Operating Systems: A Modern Perspective, Chapter 6

The Abstract Machine Interface Application Program Abstract Machine Instructions Trap Instruction Supervisor Mode Instructions fork() create() open() OS User Mode Instructions User Mode Instructions Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Context Switching Executable Memory Initialization 1 Process Manager 9 6 4 2 8 3 5 7 Interrupt Interrupt Handler P1 P2 Pn Operating Systems: A Modern Perspective, Chapter 6

Process Descriptors (PCB) Process control block (PCB), p.213 OS creates/manages process abstraction Descriptor is data structure for each process Register values (PID) Logical state Type & location of resources it holds List of resources it needs Security keys etc. (see Table 6.1 and the source code of your favorite OS) Operating Systems: A Modern Perspective, Chapter 6

Windows NT Process Descriptor EPROCESS … void *UniqueProcessId; NT Executive KPROCESS … uint32 KernelTime; uint32 UserTime; Byte state; NT Kernel Operating Systems: A Modern Perspective, Chapter 6

Windows NT Process Descriptor (2) 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 Operating Systems: A Modern Perspective, Chapter 6

Windows NT Process Descriptor (3) 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 Operating Systems: A Modern Perspective, Chapter 6

Windows NT Thread Descriptor EPROCESS KPROCESS ETHREAD KTHREAD NT Kernel NT Executive Operating Systems: A Modern Perspective, Chapter 6

Creating a Process in UNIX pid = fork(); UNIX kernel Process Table … Process Descriptor Operating Systems: A Modern Perspective, Chapter 6

Creating a Process in NT CreateProcess(…); Win32 Subsystem ntCreateProcess(…); … ntCreateThread(…); NT Executive Handle Table NT Kernel … Process Descriptor Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Windows NT Handles Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Simple State Diagram Request Done Running Request Schedule Start Allocate Blocked Ready Operating Systems: A Modern Perspective, Chapter 6

UNIX State Transition Diagram Request Wait by parent Done Running zombie Schedule Request Sleeping I/O Request Start Allocate Runnable I/O Complete Resume Traced or Stopped Uninterruptible Sleep Operating Systems: A Modern Perspective, Chapter 6

Windows NT Thread States CreateThread Terminated Initialized Reinitialize Activate Dispatch Exit Wait Waiting Ready Running Wait Complete Wait Complete Select Preempt Transition Dispatch Standby Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Resources Resource: Anything that a process can request, then be blocked because that thing is not available. R = {Rj | 0  j < m} = resource types C = {cj  0 |  RjR (0  j < m)} = units of Rj available Reusable resource: After a unit of the resource has been allocated, it must ultimately be released back to the system. E.g., CPU, primary memory, disk space, … The maximum value for cj is the number of units of that resource Consumable resource: There is no need to release a resource after it has been acquired. E.g., a message, input data, … Notice that cj is unbounded. Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Using the Model There is a resource manager, Mgr(Rj) for every Rj pi can only request ni  cj units of reusable Rj pi can request unbounded # of units of consumable Rj Process pi can request units of Rj if it is currently running request Mgr(Rj) can allocate units of Rj to pi allocate Mgr(Rj) Process Operating Systems: A Modern Perspective, Chapter 6

A Generic Resource Manager Blocked Processes Policy Process request() Process release() Resource Pool Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 Process Hierarchies Parent-child relationship may be significant: parent controls children’s execution Request Done Running Yield Suspend Request Schedule Suspend Start Ready-Active Activate Ready-Suspended Allocate Allocate Suspend Blocked-Active Blocked-Suspended Activate Operating Systems: A Modern Perspective, Chapter 6

Process Manager Overview Program Process Abstract Computing Environment Deadlock Process Description File Manager Protection Synchronization Device Manager Memory Manager Resource Manager Scheduler Devices Memory CPU Other H/W Operating Systems: A Modern Perspective, Chapter 6

Operating Systems: A Modern Perspective, Chapter 6 UNIX Organization Process Libraries Process Process System Call Interface Deadlock Process Description File Manager Protection Synchronization Device Manager Memory Manager Resource Manager Scheduler Monolithic Kernel Devices Memory CPU Other H/W Operating Systems: A Modern Perspective, Chapter 6

Windows NT Organization Process Process T T Process T T T T Libraries T T T Subsystem Subsystem Subsystem User I/O Subsystem NT Executive NT Kernel Hardware Abstraction Layer Processor(s) Main Memory Devices Operating Systems: A Modern Perspective, Chapter 6