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

Os CH - 2

Uploaded by

faimp212
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Os CH - 2

Uploaded by

faimp212
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

OS CH_2 : Processes and Threads

PRTOCESS :
• A process is a smallest unit of work that is scheduled by operating system.
• A process is basically a program under execution.
• A process needs CPU time, memory, files and I/O devices, to complete its task.
• The process concept helps to explain, understand and organize execution of programs in
an OS.
• A process is an entity which represents the basic task.
• When a program is loaded into the memory and it becomes a process. The process
contains program counter which specify the next instruction of executed.
An process has four section ie. Text, data, heap, stak section.
**PROCESSES STATES :
• The current activity of a process is known New
as its state. The process state the current admitted Interrupt exit
Terminated
status of the process.
• The process state is an indicator of the Ready Running
process.
• The change in a state of a process is Scheduler dispatch
I/O or Event completion I/O or Event wait
known as state transition of a process.
Waiting
• A process may be in one of the following
states depending on the current activity of the process:
New: A process is said to be new state if it is being created.
Ready: A process is said to be ready state if it is ready for the execution and waiting for the CPU to
be allocated to it.
Running State: A process is said to be in running state if the CPU has been allocated to it
Waiting state : A process is said to be in waiting state if it has been blocked by some event.
Terminated: A process is said to be terminated state if it has completed its execution.
Process Control Block (PCB) :
Each process is represented in the operating system by a Process Control Block (PCB) also
called as Task Control Block (TCB).
• The operating system collect all information about a particular process into a data
structure called a PCB.
• When a process is created, operating system creates a corresponding PCB.
• The basic purpose of PCB is to indicate the progress of a process.
• the operating system maintains the information about each process in a record or a data
structure called Process Control Block (PCB).
A PCB keeps the following information-
Poiter, process state, process number, priority, program counter, CPU resisters, CPU
scheduling information, memory management information, accounting information, I/O
information, file management.
PROCESS SCHEDULING :
• Process scheduling is an part of multiprogramming operating systems which allow more
than one process to be loaded into the memory at a time.
• When two or more processes compete for the CPU at the same time then choice has to be
made which process to allocate. This procedure of determining the next process to be
executed on the CPU is called process scheduling and the module of operating system that
makes this decision is called the scheduler.
Scheduling Queue :
• The operating system maintains all PCBs in process scheduling queues.
• The operating system maintains a separate queue for each of the process states.
• When the state of a process is changed, its PCB is unlinked from its current queue and moved to its new
state queue.
• The operating system maintain job queue, redy queue.
Job queue : job queue keeps all the processes in the system.
Ready queue : A new process is always put in this queue.
*Device queue : The list of processes waiting for a particular I/O device is called a Device queue.
*Types of Schedulers :
• Schedulers are special system software which handles process scheduling.
• The main task of scheduler is to select the jobs and decide which process can run.
• There are three different types of scheduler ie. long-term scheduler, medium-term scheduler and
short-term scheduler.
Short-term Scheduler :
An short-term scheduler is also colled CPU Scheduler or Process Scheduler.
• the work of Short-term scheduler is to selects a job from ready queue and submits it to
CPU.
• The main objective of short-term scheduler is to increase system performance.
• Short-term schedulers, also known as dispatchers.
• short-term scheduler has very less work to do.
Medium-term Scheduler:
• Medium term scheduling is a part of swapping so it is also known swapper.
• Swapping is term associated with the medium-term scheduler
• The medium term scheduler temporarily removes processes from main memory and
places them on secondary memory
• Medium-term scheduling removes the processes from the memory.
• It reduces the degree of multiprogramming.
Context Switch :
• The context switch is a feature of a multitasking operating system.
• Switching the CPU to another process requires saving the state of the old process and loading the saved
state for the new process. This task is known as a context switch.
• A context switch is the mechanism to store and restore the state or context of a CPU in Process Control
Block (PCB).
• Using context switch technique, a context switcher enables multiple processes to share a single CPU.
Threads :
• A thread, sometimes called a Light Weight Process (LWP). A thread is a basic unit of CPU utilization
• a thread is a single sequential flow of execution of tasks of a process so it is known as thread.
*Differece between user level & keral level Threads :

User Level Threads Kernel Level Threads

User level threads are faster to create and manage. Kernel level threads are slower to create and
manage.

Implemented by a thread library at the user level. Operating system support directly to kernel
threads.
User level thread can run on any operating system. Kernel level threads are specific to the operating
system.
Multithread application cannot take advantage of Kernel routines themselves can be multithreaded.
multiprocessing.
Benefits Of Threads :
1. Resource Sharing : All the threads of a process share its resources such as memory, data,
files
2. Responsiveness: Program responsiveness allows a program to run even if part of it is
blocked using multithreading.
3. Efficient Communication: Communication between multiple threads is easier, as the
threads shares common address space.
One-to-One Model :
• In one-to-one thread model, there are relationship between a user-level thread to a
kernel-level thread.
• The one-to-one model maps each user thread to a kernel thread.
Advantages: 1. This model provides more concurrency than the many to one model.
Disadvantages: 1. In one-to-one model Each user thread, the kernel thread is required.
Many-to-One Model :
• The many-to-one model maps many user level threads to one kernel thread.
• in Many-to-One Model Only one thread can access the kernel at a time.
Advantages: 1. One kernel thread controls multiple user threads.
Disadvantages: 1. The disadvantage is entire process will block if a thread makes blocking
system call.
Many-to-Many Model :
• In this model, many user level threads map to the Kernel thread .
• The number of Kernel threads may be specific to either a particular application or a
particular machine.
• IRIX, HP-UX and Tru64 UNIX support many to many thread model.
Advantages: 1. Many threads can be created as per user’s requirement
Disadvantages:.Low performance.
Thread Libraries :
• A thread library provides an API ot the programer for creating and managing threads
• A thread library can be implemented either in the user space or in the kernel space.

You might also like