Professional Documents
Culture Documents
Process-management
Process-management
wait()
close()
sleep()
File Mgr
fork()
signal()
Device Mgr
CC semctl()
Hardware
Program
Program SetWaitableTimer()
Memory Mgr
CreateProcess() Process Mgr
CreateThread()
CloseHandle()
OS
WaitForSingleObject()
Process Management 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 synchronize the operation with one another (Chapters 8-9)
• Mechanisms to handle deadlock (Chapter 10)
Initializing the Machine
• Power up fetch-execute cycle begins
• Initial (or hardware) process begins to run
• Executes ROM diagnostic program
• Then bootstrap loads the OS
• OS initialization
• Setup & initialize all system data structures (this creates process & resource
abstractions)
• Initialize all devices
• Start daemons – including idle process
• Branches to the scheduler
Hardware Process Starts
Program
Hardware
process
Switch to
another
program
Process Abstraction Layers
pi, pj, and pk each
Pi Pj Pk
have their own
Process Mgr Virt Term Virt Term Virt Term
virtual terminal
Window Mgr interface
File Deadlock
Deadlock Process
Process
Manager Protection Description
Description
Protection
Synchronization
Synchronization
Device Memory Resource
Scheduler Resource
Resource
Manager Manager Scheduler Resource
Resource
Manager
Resource
Manager
Manager
Manager
Manager
Manager
Devices
Devices Memory
Memory CPU
CPU Other
OtherH/W
H/W
Unix Organization
Process Process
Process
Libraries Process
Libraries Process
Process
System
SystemCall
CallInterface
Interface
File Deadlock
Deadlock Process
Process
Manager Protection Description
Description
Protection
Synchronization
Synchronization
Device Memory Resource
Scheduler Resource
Resource
Resource
Manager Manager Scheduler Resource
Manager
Resource
Manager
Manager
Manager
Monolithic Kernel Manager
Manager
Devices
Devices Memory
Memory CPU
CPU Other
OtherH/W
H/W
NT Organization
Process T Process
Process
Process T T
T T T T
T Process
Process
T
Libraries
Libraries
Subsystem
Subsystem Subsystem
Subsystem Subsystem
Subsystem
User
Supervisor
NT Executive
NT Kernel I/O
I/OSubsystem
Subsystem
Hardware
HardwareAbstraction
AbstractionLayer
Layer
pid = fork();
UNIX
UNIXkernel
kernel
Process Table
…
Process Descriptor
Creating a Process in NT
CreateProcess(…);
Win32
Win32Subsystem
Subsystem
ntCreateProcess(…);
…
ntCreateThread(…);
NT
NTExecutive
Executive
Handle Table
NT
NTKernel
Kernel
…
Process Descriptor
Handles
Application
Handle
User Space
Supervisor Space
Executive Object
NT Executive
Kernel
Object
NT Kernel
NT Process Descriptor
User Space
Supervisor Space
NT Executive
EPROCESS ETHREAD
NT Kernel
KPROCESS
(PCB)
KTHREAD
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
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
Resource Model
Resource: Anything that a process can request, then be
blocked because that thing is not available.
allocate
release
Process
Process
Resource Manager Design
Mgr(Rj)
request release
allocate
release
allocate
release
Process
Process
allocate
Resource Pool
Address Space
Primary
Primary
Memory
Memory
Address Space
Process
Process Mailboxes
Files
System services
Other objects
Defining 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
The Compile Time Component
Source
Modules
Translator
Translator Relocatable
Modules
Loader Executable
Loader Program
Address Space
AddressSpace
Map
Map
Map
Map
Processes &Threads
Resources
State
Stack
State
Static data
Program Stack
Process State (Version 1)
Request
Done
Running
Request Schedule
Allocate Start
Blocked Ready
Process State (UNIX)
Request
Wait by
parent Done
Running
zombie Schedule
Request
Sleeping I/O Request
Allocate
Start
Runnable
I/O Complete Resume
Request
Done
Running
Yield Suspend
Request Schedule
Suspend Start
Ready-Active
Activate Ready-Suspended
Allocate Allocate
Suspend
Blocked-Active Blocked-Suspended
Activate