0% found this document useful (0 votes)
2 views

OS

A process is an executing program that includes various components such as program code and a process control block (PCB) which stores its information. Processes can be independent or cooperating, and they transition through different states like new, ready, running, waiting, and terminated. Threads, as lightweight processes, share resources within a process and can enhance performance through multithreading, which allows for concurrent execution on single or multi-core CPUs.

Uploaded by

anshuchoubeyark
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)
2 views

OS

A process is an executing program that includes various components such as program code and a process control block (PCB) which stores its information. Processes can be independent or cooperating, and they transition through different states like new, ready, running, waiting, and terminated. Threads, as lightweight processes, share resources within a process and can enhance performance through multithreading, which allows for concurrent execution on single or multi-core CPUs.

Uploaded by

anshuchoubeyark
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
You are on page 1/ 3

Process

1. Definition of Process

●​ A process is a program in execution.


●​ It is an active entity, unlike a program which is a passive set of
instructions.
●​ A process includes:
○​ Program code (text section)
○​ Program counter
○​ Stack
○​ Data section
○​ Heap

2. Process Relationship

●​ Parent and Child Process:


○​ A process can create child processes using system calls (e.g., fork() in Unix).
○​ The parent may wait for the child to terminate or run concurrently.
●​ Independent vs. Cooperating Processes:
○​ Independent: Cannot affect or be affected by other processes.
○​ Cooperating: Can share data and resources with other processes (e.g., IPC – Inter-Process
Communication).
●​ Process Hierarchy (Tree):
○​ Processes can be organized in a tree-like structure, where each process has one parent and
possibly multiple children.

3. Different States of a Process

State Description

New Process is being created

Ready Waiting to be assigned to a processor

Running Instructions are being executed

Waiting (Blocked) Waiting for an event (like I/O completion)

Terminated Process has finished execution


5. Process Control Block (PCB)

The PCB is a data structure used by the operating system to store all
information about a process.

Contents of PCB:

●​ Process ID (PID): Unique identifier


●​ Process State: Current state (ready, running, etc.)
●​ Program Counter: Address of the next instruction
●​ CPU Registers: Values of all CPU registers
●​ Memory Management Info: Page tables, segment tables
●​ Accounting Info: CPU usage, process priority
●​ I/O Status Info: List of open files, devices

6. Context Switching

●​ Definition: The process of storing the state of a currently running process and loading the state of the
next ready process.
●​ Occurs when the CPU switches from one process to another.
●​ The OS saves the context (CPU state) of the current process in its PCB and loads the context of the
next process.

Steps in Context Switching:

1.​ Save context of current process in its PCB.


2.​ Load context of the next scheduled process from its PCB.
3.​ Update CPU registers and program counter.
4.​ Resume execution of the new process.

Note: Context switching introduces overhead, as no useful work is done during the switch.

Threads

1. Definition of Thread

●​ A thread is the smallest unit of CPU


execution within a process.
●​ Also known as a lightweight process.
●​ Each thread shares the process's resources
(code, data, files) but has its own:
○​ Program counter
○​ Register set
○​ Stack
2. Various States of a Thread

●​ New: Thread is created.


●​ Ready: Waiting for CPU scheduling.
●​ Running: Currently executing on a CPU.
●​ Blocked/Waiting: Waiting for an event or resource.
●​ Terminated: Finished execution.

3. Benefits of Threads

●​ Responsiveness: Multithreaded programs can remain responsive even if part of the program is
blocked.
●​ Resource Sharing: Threads within a process share resources, reducing overhead.
●​ Economy: More efficient to create and switch threads than processes.
●​ Scalability: Can take advantage of multiprocessor architectures.

4. Types of Threads

●​ User-Level Threads (ULT):


○​ Managed by user-level libraries.
○​ Fast to create and manage.
○​ OS is unaware of these threads.
●​ Kernel-Level Threads (KLT):
○​ Managed directly by the operating system.
○​ Better support for multiprocessing.
○​ Slower due to overhead.
●​ Hybrid Threading Models:
○​ Combine features of ULT and KLT.
○​ Example: Many-to-Many model.

5. Concept of Multithreading

●​ Multithreading refers to the ability of a CPU (or single core) to manage multiple threads of execution
within a single process.
●​ Single-core CPU: Multithreading is time-sliced.
●​ Multi-core CPU: Threads can run in parallel.

Advantages of Multithreading:

●​ Improved application performance


●​ Simplified program structure for concurrent tasks
●​ Better system resource utilization

You might also like