Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

PROCESS MODEL LIFE Dr.

Salahuddin Shaikh
CYCLE
CONTENT
Process model lifecycle
Multitasking, multiprocessing, multi-threading
Process & threads
User level threads & kernel level threads
PROCESS MODEL LIFECYCLE
A process is essentially running software. The execution of
any process must occur in a specific order. A process refers to
an entity that helps in representing the fundamental unit of
work that must be implemented in any system.
In other words, we write the computer programs in the form of
a text file, thus when we run them, these turn into processes
that complete all of the duties specified in the program.
PROCESS MODEL LIFECYCLE
When a process runs, it goes through many states. Distinct
operating systems have different stages, and the names of these
states are not standardized. In general, a process can be in one
of the five states listed below at any given time.
PROCESS MODEL LIFECYCLE
PROCESS MODEL LIFECYCLE
PROCESS MODEL LIFECYCLE
1. NEW STATE:
Conditions for Transition:
When a process is started/created first, it is in this state.
A process enters the New state when it is initially created by
the operating system.
Activities in the State:
In the New state, the operating system allocates resources to
the process, initializes its data structures, and prepares it for
execution.
2. READY STATE:
Conditions for Transition:
A process moves to the Ready state when it has been created and is awaiting
CPU time for execution.
This can happen after the process is initially loaded into memory or when it
becomes ready to execute after being blocked or after voluntarily giving up
the CPU.
Activities in the State:
While in the Ready state, the process is waiting for the CPU scheduler to
allocate CPU time. It is prepared for execution, and its context is stored,
allowing for a quick transition to the Running state.
3. RUNNING STATE:
Conditions for Transition:
A process enters the Running state when the CPU scheduler
allocates CPU time to it from the pool of ready processes.
Activities in the State:
In the Running state, the process is actively executing
instructions on the CPU. It continues its computations until it
voluntarily releases the CPU or gets preempted by the
scheduler.
4. BLOCKED STATE:
Conditions for Transition:
A process transitions to the Blocked state when it is waiting for
an event (e.g., I/O operation completion, resource availability)
that will allow it to proceed.
Activities in the State:
While in the Blocked state, the process cannot make progress
until the specified event occurs. The operating system may
suspend the process, freeing up system resources until the event
triggers a transition back to the Ready state.
5. EXIT STATE (TERMINATED):
Conditions for Transition:
A process enters the Exit state when it completes its execution
or is terminated by the operating system.
Activities in the State:
In the Exit state, the operating system releases all resources
allocated to the process, updates process accounting
information, and ensures a graceful termination. The process
may also return an exit status that can be used by the parent
process or the system.
SUSPEND READY:

The process is temporarily removed from the ready queue.


This state occurs when the operating system decides to suspend the
execution of a process that is in the ready state.
Common reasons for suspension include priority changes, resource
constraints, or policy decisions.
Example Scenario:
A high-priority process enters the ready state, causing the operating
system to temporarily suspend a lower-priority process in the ready
queue.
SUSPEND WAIT:
The process is temporarily removed from the execution queue while
waiting for an event.
This state occurs when a process moves to the blocked state but is
further suspended to free up resources for other processes.
Example Scenario:
A process initiates an I/O operation and moves to the blocked state.
However, due to resource constraints or policy decisions, the operating
system decides to suspend the blocked process temporarily.
RESUMING FROM SUSPEND:
Processes in the suspend state can be resumed when the conditions
that led to their suspension are resolved. Once resumed, they
typically move back to their original state (ready or blocked) in the
process lifecycle.
Use Cases for Suspend:
Priority Adjustments:
Suspend Ready can be used to temporarily set aside lower-
priority processes when higher-priority ones become available.
RESUMING FROM SUSPEND:
Resource Management:
Suspend Wait helps manage resources efficiently by temporarily
suspending processes in the blocked state, allowing other processes
to utilize available resources.
Power Management:
Suspend states are also used in power management strategies to
reduce energy consumption when processes are not actively
executing.
TYPES OF SCHEDULERS
1. Long-term – performance: Decides how many processes should be
made to stay in the ready state. This decides the degree of
multiprogramming. Once a decision is taken it lasts for a long time which
also indicates that it runs infrequently. Hence it is called a long-term
scheduler.
2. Short-term – Context switching time: Short-term scheduler will
decide which process is to be executed next and then it will call the
dispatcher. A dispatcher is a software that moves the process from ready to
run and vice versa. In other words, it is context switching. It runs
frequently. Short-term scheduler is also called CPU scheduler.
TYPES OF SCHEDULERS
Medium-term – Swapping time: Suspension decision is taken by the
medium-term scheduler. The medium-term scheduler is used for swapping
which is moving the process from main memory to secondary and vice
versa. The swapping is done to reduce degree of multiprogramming.
Multitasking, Multiprocessing,
Multi-threading
MULTI-TASKING
Multi-tasking is the logical extension of multiprogramming. In this
system, the CPU executes multiple jobs by switching among them
typically using a small time quantum, and these switches occur so
frequently that the users can interact with each program while it is
running. Multitasking is further classified into two categories: Single User
& Multiuser.
MULTI-PROCESSING :
Multiprocessing is a system that has two or more than two processors. In
this, CPUs are added for increasing computing speed of the system.
Because of Multiprocessing, there are many processes that are executed
simultaneously. Multiprocessing is further classified into two categories:
Symmetric Multiprocessing and Asymmetric Multiprocessing.
MULTI-THREADING
Multithreading is a system in which many threads are created from a
process through which the computer power is increased. In multithreading,
CPU is provided in order to execute many threads from a process at a time,
and in multithreading, process creation is performed according to cost.
Unlike multitasking, multithreading provides the same memory and
resources to the processes for execution.
LET’S SEE THE DIFFERENCE
BETWEEN MULTITASKING
AND MULTITHREADING:
Multitasking Multithreading
1 In multitasking, users are allowed to perform many While in multithreading, many threads are created from a
tasks by CPU. process through which computer power is increased.
2 Multitasking involves often CPU switching While in multithreading also, CPU switching is often
between the tasks. involved between the threads.
3 In multitasking, the processes share separate While in multithreading, processes are allocated the same
memory. memory.
4 The multitasking component involves While the multithreading component does not involve
multiprocessing. multiprocessing.
5 In multitasking, the CPU is provided in order to While in multithreading also, a CPU is provided in order to
execute many tasks at a time. execute many threads from a process at a time.
6 In multitasking, processes don’t share the same While in multithreading, each process shares the same
resources, each process is allocated separate resources.
resources.
7 Multitasking is slow compared to multithreading. While multithreading is faster.
PROCESS & THREADS
PROCESS
A process is an instance of a computer program that is getting executed.
A computer program is passive and contains a set of instructions (code)
stored in the file system. A process is active and works by loading the
program into memory and executing it.
A process consists of the following resources:
Text (machine code of the compiled program)
Data (global, static, constant, and uninitialized variables)
Heap (dynamic memory allocation)
Stack (temporary data such as local variables, function calls, parameters,
return address, etc)
THREADS
Thread is the segment of a process which means a process can have
multiple threads and these multiple threads are contained within a
process. A thread has three states: Running, Ready, and Blocked.
The thread takes less time to terminate as compared to the process but
unlike the process, threads do not isolate.
PROCESS & THREAD
USER LEVEL THREADS &
KERNEL LEVEL THREADS
User-Level Thread-
The User-level Threads are implemented by the user-level software.
the user-level threads are basically created and implemented by the
thread library which OS provides as an API for creating the managing
synchronizing threads. it is faster than the kernel-level threads, it is
basically represented by the program counter, stack, register, and
PCB.
Example – user threads library includes POSIX threads, Mach C-
Threads
USER LEVEL THREADS &
KERNEL LEVEL THREADS
Kernel-Level Thread –
So, in terms of the Operating systems basically, the threads are the unit of
execution within a process. and the kernel level threads are also kinds of
threads which is directly handled via kernel threads management. The
Kernel-level threads are directly handled by the OS directly whereas the
thread’s management is done by the kernel.
In the Kernel Level Threads, Each thread is self-organizing and the kernel
provides each thread with its own context with information about the
thread’s status, such as its name, group, and priority.
Example – The example of Kernel-level threads are Java threads, POSIX
threads, etc.
USER LEVEL THREADS &
KERNEL LEVEL THREADS
User-level threads offer greater flexibility and lightweight thread
management but may not provide true parallelism on multi-core
systems. Kernel-level threads offer better resource management
and true parallel execution but come with higher overhead and
potentially less flexibility. In some cases, a hybrid approach that
combines both user-level and kernel-level threads can be used to
leverage the advantages of both approaches.
USER LEVEL THREADS &
KERNEL LEVEL THREADS

You might also like