0% found this document useful (0 votes)
5 views26 pages

Chapter 5 Process Management

The document discusses the concepts of programs and processes, emphasizing the role of the Process Control Block (PCB) in managing process information and execution status. It explains the importance of Process IDs (PIDs), the Program Counter (PC), and process states in operating systems, as well as the differences between single-threaded and multi-threaded processes. Additionally, it covers user-level and kernel-level threads, their management, advantages, and limitations, highlighting the use of hybrid approaches in modern systems.

Uploaded by

moongahumphrey56
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views26 pages

Chapter 5 Process Management

The document discusses the concepts of programs and processes, emphasizing the role of the Process Control Block (PCB) in managing process information and execution status. It explains the importance of Process IDs (PIDs), the Program Counter (PC), and process states in operating systems, as well as the differences between single-threaded and multi-threaded processes. Additionally, it covers user-level and kernel-level threads, their management, advantages, and limitations, highlighting the use of hybrid approaches in modern systems.

Uploaded by

moongahumphrey56
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

S.

Sianga
Kwame Nkrumah University
ICT - Department
Program:
 A passive entity as it resides in
the secondary memory.
Process:
 A program in execution.
 Active entity as it is created
during execution
 A PCB is a data structure used by the
operating system to store and manage all
information related to a process.
 As the OS supports multi-programming,
it needs to keep track of all the
processes.
 For this task, the process control block
(PCB) is used to track the process’s
execution status.
 Each block of memory contains
information about the process state,
program counter, stack pointer, status of
opened files, scheduling algorithms, etc.
Process ID (PID) : Unique
process ID
Program Counter (PC):
Tracks Addresses
Process State: Different
states
Priority: priority level
assigned to a process
CPU Registers – Stores
process execution state.
 A PID unique numerical identifier
assigned by the OS to each process. It is
used by the OS to identify, track, and
manage processes in the system.
 ATTRIBUTES:
 Uniqueness: Each process has a unique
PID at any given time.
 Assignment: The OS assigns a PID when
a process is created.
 Usage: PIDs are used for process
management tasks like monitoring,
signaling, and termination.
 Recycling: Once a process ends, its PID
may be reused for new processes.
 Parent-Child Relationship: Processes
can spawn child processes, which receive
their own unique PIDs.
 The Program Counter (PC) is a special
register in the CPU that holds the memory
address of the next instruction to be
executed.
 Functions of the Program Counter:
 Stores the Next Instruction Address
 The PC keeps track of the memory location
of the next instruction in a program.
 Increments Automatically
 After fetching an instruction, the PC is
usually incremented to point to the next
sequential instruction.
 Handles Control Flow Changes
 When a jump, branch, or function call occurs,
the PC updates with the new instruction
address instead of incrementing
sequentially.
 Process priority determines how
much CPU time a process gets
relative to others.
 Operating systems use priority
levels to schedule and manage
processes efficiently.
 Windows uses a priority class
system with these levels:
 Real-time (Highest)
 High
 Above Normal
 Normal (Default)
 Below Normal
 Low (Lowest)
 A process is being created.
 The OS assigns a Process
Control Block (PCB) and
necessary resources.
 The process moves to the
Ready state after initialization.
 Example: A user launches a
program, and the OS begins
allocating memory and
resources to start execution.
 The process has all required
resources except CPU time.
 It is waiting in the Ready
Queue to be scheduled.
 The CPU Scheduler selects a
process to run.
 Example: Multiple applications
are open, but only one can
execute at a time. Others wait in
the ready queue.
 The CPU is executing the
process instructions.
 Only one process per CPU
core can be in the running
state.
 A process remains in this state
until:
• It is interrupted by the OS.
• It completes execution.
• It moves to a waiting state.
• Example: A user is typing in a
word processor, and the OS
gives CPU time to that
application.
 A process is waiting for an
event (e.g., I/O operation,
resource availability).
•It cannot proceed until the
event occurs.
•The process moves back to
the Ready state when the
event is resolved.
Example: A program waits for a
file to load from the disk.
 The process has completed
execution or was forcibly
stopped.
 The OS deallocates resources
and removes the process from
memory.
 Example: Closing a browser
window or a background task
finishing execution.
[Link] Ready
• The process is in
secondary storage (disk)
and waiting to move to
main memory.
• Used in memory
management strategies like
swapping.
[Link] Waiting
• A waiting process is moved
to secondary storage due
to memory constraints.
New → Ready → Process is admitted.
Ready → Running → Process gets CPU time.
Running → Waiting → Process requests I/O.
Running → Terminated → Process completes execution.
Waiting → Ready → I/O completes, process is ready for CPU.
A thread is the smallest unit of execution within
a process. (lightweight process)
 Process consists of one or more threads.
 A process can have multiple threads that share
resources such as memory, code, and open
files but execute independently.
A thread has its own register set and a unique
program counter
Single-Threaded Process:
 A process contains only one
thread of execution.
 If the thread is blocked (e.g.,
waiting for I/O), the entire
process is blocked.
 Example: A simple program that
performs a single task
sequentially.
A multi-threaded process is a process that
contains two or more threads of execution
running concurrently.
 Multiple threads perform different tasks
at the same time
 Threads share the same memory, code,
and open files
 Each thread has its own program counter
and registers
 If one thread is blocked (e.g., waiting for
I/O), other threads can continue
running
 This improves performance,
responsiveness, and CPU utilization
Multi-Threaded Process
 Improves CPU utilization
 Enhances application
responsiveness
 Allows parallel execution on
multi-core CPUs
 Threads share resources but
have separate program
counters and registers
 Faster context switching
compared to processes
 Responsiveness
 The application remains responsive even if one thread is
blocked or busy.
 Resource Sharing
 Threads share the same memory, code, and open files,
making communication faster and easier.
 Economy
 Creating and switching between threads is faster and
uses fewer resources than processes.
 Utilization of Multiprocessor Architectures
 Multiple threads can run on different CPU cores
simultaneously, improving performance.
 User-Level Threads (ULTs)
 These are threads that are managed entirely in user
space, without direct support from the operating system
kernel. The thread library (not the OS) is responsible for
creating, scheduling, and managing these threads.
 Managed by a user-level thread library
 The kernel is unaware of individual threads
 Thread creation and context switching are fast
 If one thread blocks (e.g., system call), the entire process
may block
 Scheduling is done at the user level
 Faster switching but cannot use multiple CPU cores.
 Kernel-Level Threads (KLTs)
These are threads that are created, managed, and
scheduled directly by the operating system kernel.
The kernel is fully aware of each thread and treats
them as individual units of execution.
 Managed by the operating system kernel
 The kernel is aware of all threads
 Threads can be scheduled independently
 Supports true parallelism on multi-core processors
 Blocking of one thread does not block the entire process
 Many-to-One Model
 Multiple user threads map to a single kernel thread.
 Disadvantage: If one thread blocks, the entire process blocks.
 One-to-One Model
 Each user thread maps to a separate kernel thread.
 True parallel execution but high resource consumption.
 Many-to-Many Model
 Multiple user threads map to multiple kernel threads dynamically.
 Best balance between performance and flexibility.
 Feature User-Level Threads (ULTs) Kernel-Level Threads (KLTs)

 Managed By User-space libraries OS Kernel

 Context Switch Fast (No kernel mode switch) Slower (Involves kernel mode switch)

 Parallelism No true parallel execution Can run on multiple cores

 Blocking Blocks entire process Only the blocked thread is affected

 OS Awareness OS is unaware of threads OS manages and schedules threads


 User-Level Threads provide fast and flexible thread
management but come with limitations like blocking issues
and lack of multi-core utilization. Modern systems often use
a hybrid approach (mixing ULTs and KLTs) for efficiency

You might also like