KEMBAR78
Unit 2 Os | PDF | Process (Computing) | Thread (Computing)
0% found this document useful (0 votes)
4 views4 pages

Unit 2 Os

Uploaded by

RanjanKumar
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)
4 views4 pages

Unit 2 Os

Uploaded by

RanjanKumar
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/ 4

Process Management

1. Process Definition:

A process is a program in execution. It includes the program code, current activity, and
process state. It is an active entity, unlike a program, which is a passive set of instructions.

2. Process States:

A process typically goes through the following states:

 New: Process is being created.


 Ready: Process is waiting to be assigned to the CPU.
 Running: Process is currently being executed.
 Waiting (Blocked): Process is waiting for some event (like I/O).
 Terminated: Process has finished execution.

3. Process State Transitions:

Transition Description
New → Ready Process has been created and is ready to run.
Ready → Running CPU scheduler selects the process for execution.
Running → Waiting Process requests I/O and moves to waiting state.
Running → Ready Preemption: CPU is taken away and process goes back to ready.
Waiting → Ready I/O or event completed, process becomes ready.
Running → Terminated Process finishes execution or is killed.

4. Process Scheduling:

Process Scheduling is the mechanism by which the operating system decides which process
gets to use the CPU next.

 Types of Schedulers:
o Long-term scheduler (job scheduler): Selects processes from the pool and
loads them into memory.
o Short-term scheduler (CPU scheduler): Selects among ready processes for
execution.
o Medium-term scheduler: Suspends/resumes processes to control
multitasking.
 Scheduling Algorithms:
o FCFS (First Come First Serve)
o SJF (Shortest Job First)
o Round Robin

5. Process Control Block (PCB):

A PCB is a data structure maintained by the OS to store all information about a process.

Contents of PCB:

 Process ID
 Process State
 Program Counter
 CPU Registers
 Memory Management Information
 Accounting Information
 I/O Status

6. Threads:

A thread is the smallest unit of CPU execution. Multiple threads can exist within the same
process and share the same resources.

7. Concept of Multithreading:

Multithreading allows multiple threads to run concurrently within a single process,


improving performance and responsiveness.

8. Benefits of Threads:

 Improved responsiveness
 Resource sharing between threads
 Economy (faster context switching than processes)
 Scalability on multiprocessor systems

9. Types of Threads:

 User-level Threads (ULT): Managed by user-level libraries; faster but cannot


leverage multiprocessor systems effectively.
 Kernel-level Threads (KLT): Managed by the OS; more overhead but better for
multiprocessing.
 Hybrid Threads: Combine features of both ULT and KLT.

Process Scheduling
1. Definition:

Process Scheduling is the activity of selecting a process from the ready queue and allocating
the CPU to it. It is performed by the CPU scheduler, which decides the order in which
processes run.

2. Scheduling Objectives:

The main goals of CPU scheduling are:

 Maximize CPU utilization (keep the CPU as busy as possible)


 Maximize throughput (number of processes completed per unit time)
 Minimize turnaround time (total time from submission to completion)
 Minimize waiting time (time a process waits in the ready queue)
 Minimize response time (time from request submission to first response)
 Fairness (every process gets a fair share of CPU)

3. Scheduling Algorithms:

A. Preemptive vs Non-preemptive Scheduling:


Feature Preemptive Non-preemptive

CPU can be taken back Yes No (once given, it runs till finish or wait)

Response Time Better May be poor

Complexity Higher Lower

4. Common Scheduling Algorithms:

a. First Come First Serve (FCFS):

 Type: Non-preemptive
 Idea: Process that arrives first is executed first
 Drawbacks: Long jobs can block short ones (convoy effect)
b. Shortest Job First (SJF):

 Type: Can be preemptive or non-preemptive


 Idea: Execute the process with the shortest CPU burst time
 Preemptive SJF: Also known as Shortest Remaining Time First (SRTF)
 Drawback: Requires prediction of burst time, may lead to starvation

c. Round Robin (RR):

 Type: Preemptive
 Idea: Each process gets a small unit of CPU time (time quantum), then goes back to
the ready queue if not finished
 Advantage: Good for time-sharing systems
 Drawback: Performance depends on the time quantum size

You might also like