Outline Process Management Process manager Hardware process Process

  • Slides: 34
Download presentation
Outline • Process Management – Process manager – Hardware process – Process abstraction •

Outline • Process Management – Process manager – Hardware process – Process abstraction • Process descriptor – Thread abstraction 2/18/2021 COP 4610 1

Basic OS Functions 2/18/2021 COP 4610 2

Basic OS Functions 2/18/2021 COP 4610 2

Process Manager • Process manager creates the process abstraction – It implements a software

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 2/18/2021 COP 4610 3

Process Manager – cont. • Process manager consists of – Basic algorithms and data

Process Manager – cont. • Process manager consists of – Basic algorithms and data structures to implement the process and resource abstractions – Managing resources used by processes/threads – Tools to create/destroy/manipulate processes and threads – Scheduling – Process synchronization – A deadlock strategy – Protection strategy 2/18/2021 COP 4610 4

Process Manager – cont. Program Process Abstract Computing Environment File Manager Deadlock Process Description

Process Manager – cont. Program Process Abstract Computing Environment File Manager Deadlock Process Description Protection Synchronization Device Memory Manager Devices 2/18/2021 Scheduler Memory CPU COP 4610 Resource Manager Other H/W 5

Implementing the Process Abstraction Pi CPU Pj CPU Pi Executable Memory Pj Executable Memory

Implementing the Process Abstraction Pi CPU Pj CPU Pi Executable Memory Pj Executable Memory Pk CPU … Pk Executable Memory OS Address Space Pi Address Space CPU ALU Pk Address Space Control Unit 2/18/2021 … Pj Address Space COP 4610 Machine Executable Memory OS interface 6

External View of the Process Manager Application Program Device Mgr UNIX Memory Mgr File

External View of the Process Manager Application Program Device Mgr UNIX Memory Mgr File Mgr exec() Memory Mgr File Mgr Process Mgr Device Mgr wait() Create. Thread() Close. Handle() Create. Process() Wait. For. Single. Object() Process Mgr fork() Windows Hardware 2/18/2021 COP 4610 7

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

Modern Processes and Threads Thrdj in Pi Thrdk in Pi … Pi CPU … … OS interface … 2/18/2021 COP 4610 8

Modern Processes and Threads – cont. 2/18/2021 COP 4610 9

Modern Processes and Threads – cont. 2/18/2021 COP 4610 9

Processes • A process is a sequential program in execution – The object program

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 2/18/2021 COP 4610 10

Process Address Space • Process address space – A set of locations used by

Process Address Space • Process address space – A set of locations used by a process to reference primary memory locations, OS services, and resources 2/18/2021 COP 4610 11

The Address Space Address Binding Executable Memory Process Files Other objects 2/18/2021 COP 4610

The Address Space Address Binding Executable Memory Process Files Other objects 2/18/2021 COP 4610 12

Building the Address Space • Some parts are built into the environment – 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 2/18/2021 COP 4610 13

Process Address Space – cont. 2/18/2021 COP 4610 14

Process Address Space – cont. 2/18/2021 COP 4610 14

System Overview 2/18/2021 COP 4610 15

System Overview 2/18/2021 COP 4610 15

Instruction Execution • Instruction fetch (IF) MAR PC; IR M[MAR] • Instruction Decode (ID)

Instruction Execution • Instruction fetch (IF) MAR PC; IR M[MAR] • Instruction Decode (ID) A Rs 1; B Rs 2; PC + 4 • Execution (EXE) – Depends on the instruction • Memory Access (MEM) – Depends on the instruction • Write-back (WB) 2/18/2021 COP 4610 16

The Hardware Process • Hardware process refers to the iterative activity of the control

The Hardware Process • Hardware process refers to the iterative activity of the control unit – It fetches an instruction and then executes it repeatedly 2/18/2021 COP 4610 17

Tracing the Hardware Process Hardware process progress Machine is Powered up Bootstrap Process Interrupt

Tracing the Hardware Process Hardware process progress Machine is Powered up Bootstrap Process Interrupt Loader Manager Handler P 1 Load the kernel Initialization Execute a thread Schedule Pn … Service an interrupt 2/18/2021 P, 2 COP 4610 18

Context Switching Old Thread Descriptor CPU New Thread Descriptor 2/18/2021 COP 4610 19

Context Switching Old Thread Descriptor CPU New Thread Descriptor 2/18/2021 COP 4610 19

Context Switching – cont. Executable Memory Initialization Interrupt 1 Process Manager 7 Interrupt Handler

Context Switching – cont. Executable Memory Initialization Interrupt 1 Process Manager 7 Interrupt Handler 2 4 9 8 3 P 1 P 2 5 6 Pn 2/18/2021 COP 4610 20

The Abstract Machine Interface Application Program Abstract Machine Instructions Trap Instruction User Mode Instructions

The Abstract Machine Interface Application Program Abstract Machine Instructions Trap Instruction User Mode Instructions fork() open() create() OS User Mode Instructions 2/18/2021 Supervisor Mode Instructions COP 4610 21

Process Descriptors • OS creates/manages process abstraction • Descriptor is data structure for each

Process Descriptors • OS creates/manages process abstraction • Descriptor is data structure for each process – Type & location of resources it holds – List of resources it needs – List of threads – List of child processes – Security keys 2/18/2021 COP 4610 22

Process Descriptor – cont. 2/18/2021 COP 4610 23

Process Descriptor – cont. 2/18/2021 COP 4610 23

Windows NT Process Descriptor EPROCESS KPROCESS NT Kernel NT Executive 2/18/2021 … uint 32

Windows NT Process Descriptor EPROCESS KPROCESS NT Kernel NT Executive 2/18/2021 … uint 32 … Byte … void … COP 4610 Kernel. Time; User. Time; state; *Unique. Process. Id; 24

Windows NT Process Descriptor – cont. · Kernel process object including: · · ·

Windows NT Process Descriptor – cont. · Kernel process object including: · · · 2/18/2021 Pointer to the page directory Kernel & user time Process base priority Process state List of the Kernel thread descriptors that are using this process COP 4610 25

Windows NT Process Descriptor – cont. · · · · · Parent identification Exit

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 Win 32 -specific information 2/18/2021 COP 4610 26

Thread Abstraction • The major tasks in managing a thread include – Create/destroy a

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 2/18/2021 COP 4610 27

Thread Abstraction – cont. 2/18/2021 COP 4610 28

Thread Abstraction – cont. 2/18/2021 COP 4610 28

Windows NT Thread Descriptor EPROCESS KPROCESS ETHREAD KTHREAD NT Kernel NT Executive 2/18/2021 COP

Windows NT Thread Descriptor EPROCESS KPROCESS ETHREAD KTHREAD NT Kernel NT Executive 2/18/2021 COP 4610 29

Simple State Diagram Request Done Running Request Schedule Start Allocate Ready Blocked 2/18/2021 COP

Simple State Diagram Request Done Running Request Schedule Start Allocate Ready Blocked 2/18/2021 COP 4610 30

UNIX State Transition Diagram Request Wait by parent zombie Sleeping Done Running Schedule Request

UNIX State Transition Diagram Request Wait by parent zombie Sleeping Done Running Schedule Request I/O Request Start Allocate Runnable I/O Complete Traced or Stopped Uninterruptible Sleep 2/18/2021 Resume COP 4610 31

Windows NT Thread States Create. Thread Initialized Reinitialize Activate Exit Running Waiting Wait Complete

Windows NT Thread States Create. Thread Initialized Reinitialize Activate Exit Running Waiting Wait Complete Transition Dispatch 2/18/2021 Ready Wait Complete Preempt Dispatch Select Terminated Standby COP 4610 32

Summary • Process manager – It creates abstract machines for process to run in

Summary • Process manager – It creates abstract machines for process to run in – It is achieved by time-multiplexing the hardware through context-switching – To manage processes / threads, process manager uses data structures (process descriptor and thread descriptor) to keep the information for manipulating them 2/18/2021 COP 4610 33

Session Information • COP 4610 / CGS 5765 – Section 6 – Section 2

Session Information • COP 4610 / CGS 5765 – Section 6 – Section 2 – Section 3 – Section 4 2/18/2021 Recitation time 08: 00 -08: 55 AM 09: 05 -09: 55 AM 11: 15 AM -12: 05 PM 12: 20 -1: 10 PM COP 4610 34