Implementing Processes, Threads, and Resources

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.
Slide 2-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 2 Using the Operating System 2.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Implementing Processes, Threads, and Resources.
Process Description and Control
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.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
Chapter 6 - Implementing Processes, Threads and Resources Kris Hansen Shelby Davis Jeffery Brass 3/7/05 & 3/9/05 Kris Hansen Shelby Davis Jeffery Brass.
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.
Threads, Thread management & Resource Management.
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.
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.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
What is a Process ? A program in execution.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Introduction to Operating Systems Concepts
Process concept.
Process Management Process Concept Why only the global variables?
Protection of System Resources
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Implementing Processes and Threads
Overview of today’s lecture
Operating Systems: A Modern Perspective, Chapter 6
System Structure and Process Model
System Structure and Process Model
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
Threads Chapter 4.
Process Description and Control
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
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
Processes in Unix and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
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
Chapter 3: Process Management
Presentation transcript:

Implementing Processes, Threads, and Resources

Basic OS Functions Processor(s) Main Memory Devices Process, Thread & Resource Manager Memory Manager Device File

What is a Process Classic process (used up to late 80s/early 90s) Program in execution on a von Neumann computer New abstraction divides aspects of classic process into two parts Modern process: the part that defines a customized computational framework in which a program executes Thread: the part that keeps track of code executions within this framework Classic process = modern process with 1 thread

Process Manager Process manager creates the process abstraction It implements a software environment for processes to run Algorithms that define the behavior of the operating system Data structures to preserve the state of the execution

Process Manager – cont. 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 (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)

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

Implementing the Process Abstraction OS Address Space Control Unit OS interface … Machine Executable Memory ALU CPU Pi Address Pi CPU Pi Executable Memory Pk Address Pk CPU Pk Executable Pj Address Pj CPU Pj Executable

External View of the Process Manager Hardware Application Program Device Mgr Process Mgr Memory Mgr File Mgr UNIX Windows CreateThread() CreateProcess() CloseHandle() WaitForSingleObject() fork() exec() wait()

Modern Processes and Threads OS interface … Pi CPU Thrdj in Pi Thrdk in Pi

Processes A process is a sequential program in execution The object program to be executed The data on which the program will execute Resources required by the program The threads in the process A host process environment The status of each thread’s execution Thread-specific data, such as a stack, a PC, and set of register values

Process Address Space Process address space The collection of addresses a thread can reference Normally refer to an executable memory location Can refer to OS services and resources

The Address Space Process Files Other objects Address Space Binding Executable Memory Other objects Files

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

Process Manager Responsibilities Create process abstraction Create thread abstraction Process/thread synchronization Create resource abstraction Resource protection Cooperation with device manager to implement I/O Implementation of address space

Modern Process Composed of: Address space Program to define behavior of process Data used by process Resources needed for thread execution Process created with a minimal set of resources Additional resources allocated as needed

The Hardware Process Hardware process refers to the iterative activity of the control unit Repeatedly fetching and executing instructions

Tracing the Hardware Process Bootstrap Loader Process Manager Interrupt Handler P1 P2 Pn … Machine is Powered up Initialization Load the kernel Service an interrupt Hardware process progress Execute a thread Schedule

The Abstract Machine Interface User Mode Instructions Application Program Abstract Machine Instructions Trap Instruction Supervisor Mode fork() create() open() OS

Context Switching CPU New Thread Descriptor Old Thread Descriptor

Context Switching – cont. Process Manager Interrupt Handler P1 P2 Pn Executable Memory Initialization 1 2 3 4 5 7 8 9 6

Process Descriptors OS creates/manages process abstraction Descriptor is data structure for each process Register values Logical state Type & location of resources it holds List of resources it needs List of threads List of child processes Security keys etc.

Windows NT Process Descriptor EPROCESS … void *UniqueProcessId; NT Executive KPROCESS uint32 KernelTime; uint32 UserTime; Byte state; NT Kernel

Windows NT Process Descriptor – cont. 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

Windows NT Process Descriptor – cont. 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

Thread Abstraction The major tasks in managing a thread include Create/destroy a thread Allocate thread-specific resources Manage thread context switching The thread descriptor is the data structure where the OS keeps all information to manage that thread Current state, execution stats, reference to associated process, related threads, etc.

Windows NT Thread Descriptor ETHREAD EPROCESS KPROCESS NT Kernel KTHREAD NT Executive

Creating a Process in UNIX pid = fork(); UNIX kernel Process Table … Process Descriptor

Creating a Process in NT CreateProcess(…); Win32 Subsystem ntCreateProcess(…); … ntCreateThread(…); NT Executive Handle Table NT Kernel … Process Descriptor

Windows NT Handles

Simple State Diagram Request Done Running Schedule Start Allocate Ready Blocked Running Start Schedule Request Done Allocate

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

Windows NT Thread States CreateThread Terminated Initialized Reinitialize Activate Dispatch Exit Wait Waiting Ready Running Wait Complete Wait Complete Select Preempt Transition Dispatch Standby

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 | for 0  j < m s.t. RjR} = 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.

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

A Generic Resource Manager Blocked Processes Policy Process request() Process release() Resource Pool

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

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

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

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