2. External View of the OS
Hardware
fork()
CreateProcess()
CreateThread()
close()
CloseHandle()
sleep()
semctl()
signal()
SetWaitableTimer()
wait()
WaitForSingleObject()
C
Program
OS
Process Mgr
Memory Mgr
Device Mgr
File Mgr
3. 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 synchronization the operation
with one another (Chapters 8-9)
• Mechanisms to handle deadlock (Chapter 10)
4. 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
5. Kernel Process j
Process i
ISRs
Idle Process
Hardware Process Starts
Program
Hardware
process
Switch to
another
program
BIOS
6. Process Abstraction Layers
Control
Unit
Pi
Address
Space
Pj
Address
Space
Pk
Address
Space
Hardware process
(OS) coroutines across
pi, pj, and pk under OS
control
Pi
Control
Unit
Pj
Control
Unit
Pk
Control
Unit
pi, pj, and pk each
have their own
virtual machine
OS interface
Pi
Virt Term
Pj
Virt Term
Pk
Virt Term
pi, pj, and pk each
have their own
virtual terminal
Window Mgr interface
OS
Address
Space
Process Mgr
7. Process Manager Overview
Program Process
Abstract Computing Environment
File
Manager
Memory
Manager
Device
Manager
Protection
Deadlock
Synchronization
Process
Description
CPU Other H/W
Scheduler
Resource
Manager
Resource
Manager
Resource
Manager
Memory
Devices
Process Mgr
8. System Call Interface
Unix Organization
File
Manager
Memory
Manager
Device
Manager
Protection
Deadlock
Synchronization
Process
Description
CPU Other H/W
Scheduler
Resource
Manager
Resource
Manager
Resource
Manager
Memory
Devices
Libraries
Process
Process
Process
Monolithic Kernel
9. NT Organization
Processor(s) Main Memory Devices
Libraries
Process
Process
Process
Subsystem
User
Supervisor
Subsystem Subsystem
Hardware Abstraction Layer
NT Kernel
NT Executive
I/O Subsystem
T
T
T
T
T
T T T
T
10. Process Descriptor
• 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
– Security keys
– etc. (see Table 6.1 and the source code of your
favorite OS)
11. Creating a Process in UNIX
pid = fork();
UNIX kernel
…
Process Table
Process Descriptor
12. Creating a Process in NT
CreateProcess(…);
Win32 Subsystem
ntCreateProcess(…);
…
ntCreateThread(…);
NT Executive
NT Kernel
…
Handle Table
Process Descriptor
15. 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
16. 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
17. Resource Model
R = {Rj | 0 j < m} = resource types
C = {cj 0 | RjR (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.
Resource: Anything that a process can request, then be
blocked because that thing is not available.
18. Using the Model
• There is a resource manager, Mgr(Rj) for every Rj
Mgr(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
Process
request
•Mgr(Rj) can allocate units of Rj to pi
allocate
release
•pi can release units of Rj that it holds (reusable) or
produces (consumable)
21. 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
22. The Compile Time Component
Source
Modules
Translator Relocatable
Modules
Link Editor Absolute
Program
Loader Executable
Program
Primary Memory