0% found this document useful (0 votes)
23 views13 pages

Os 2

Uploaded by

devpgaonkar3
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)
23 views13 pages

Os 2

Uploaded by

devpgaonkar3
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/ 13

PROCESS

" The most central concept in any operating system is the process: an abstraction of a running
program. Ererything else hinges on this concept.
" A process is a program in execution. A process will need certain resources- -Such as CPU
time. memory, files, and I'O devices--to accomplish its task.
" These resources are typically allocated to the process while it is executing.

" Aprocess is the nit of work in most systemns.


Systems consist of acollection of processes: operating-system processes execute system code.
and user processes execute user code.
"All these processes may execute concurrently
"A process is just an executing program, including the current ralues of the program counter.
registers. and variables.
" Conceptually. cach process has its own virtual CPU. In eality. of course, the real CPU
switches back and forth from process to process.

PROCESS & THREAD


" Moderm operating systems support
processes having multiple threads of
control.
" On systems with multiple hardware
processIng cores, these threads can run in
parallel.
" One of the mnost mportant aspects ot an
operating systen is how it schedules threads
onto available processng cores.
" So threads ae units of a Process that is
under execution.
PROCESS STATES

new admitted interrupt exit terminated

ready running

VO or event completion scheduler dispatchO or event wait


waiting

Figure 3.2 Diagram of process state.

PROCESS STATES

New: The process is being created.


"Running: Instructions are being executed.
" Waiting: The process is waiting for some event to occur (such
as an I/O completion or reception of a signal).
"Ready: The process is waiting to be assigned to a processor.
"Terminated: The process has finished execution.
OPERATIONS ON PROCESS

" PROCESSCREATION
"PROCESS SCHEDULING

" PROCESS TERMINATION

PROCESSCREATION
"Parent process create children processes, which, in turn create other
processes, forming atree of processes
"Resource sharing
"Parent and children share all resources
" Children share subset of parent's resources
" Parent and child share no resources
"Execution
Parent and children execute concurrently
" Parent waits until children terminate
PROCESS TERMINATION
" Process executes last statement and asks the operating system to delete it
(exit)
" Output data from child to parent
" Process' resources are deallocated by operating system

Termination can occur in following cases:


"A process can cause termination of another process via an appropriate
system c¡ll. Usully such system call is inyoked by the parent of the process
who isto be terminated. Other users could arbitrafily kill each others
processes.
"Parent may terminate execution of children processes (abort)
"Child has exceeded allocated resources
" Task assigned to child is no longer required
" If parent is exiting
" Some operating system do not allow child to continue if its parent
terminates. Allhildren terminated - cascading termination
process state
process number
program counter

regsters

memory limits
Bst of open fles

Figure 3.3 Process control hlock PCB)

PROCESS CONTROL BLOCK

"Each process is represented in the operating system by a process


control block (PCB)-also called a task control block. APCB is shown
in Figure 3.3.
"It containsmany pieces of informationassociated with a specific
process, including these:
D
Process state-The state may be new, ready, running, waiting, halted,
and so on.
D
Program counter-The counter indicates the address of the next
instruction tobe executed for this process

PROCESS CONTROL BLOCK


ICPU registers-The registers vary in number and type & may include
accumulators, index registers, 'stack pointers, and general-purpose
registers, plss any condition-code information.
UCPU-scheduling information- This information includes a process
priority, pointers to scheduling queues, and any other scheduling
parameters.
OMemory-management information- This information may include
such items as the value of the registers and the page tables, or the
segment tables.
OAccounting information-This information includes the amount of CPU
and real time used resources, time limits, account numbers, job or
process numbers, and so on.
D\/0 status information-This information includes the list of i/0devices
allocated to the process, a list of open files, and so on
CONTEXT SWITCHING
" When an interupt occurs, the system needs to save the current context of the process
running On the CPU core so that it can restore that context when its processing is
done. essentially suspending the process and then resuming it.
"The context is represented in the PCBof the process.
Generically. we perform astate save of the cuTent state of the CPU core. be it in
kenel or user mode, and then a state restore to resume operations.
" Switching the CPUcore to another process requires performing a state save of the
curent process and a state restore of a different process.
" This task is known as a context Switch

ex. Inpre-emptive process, the process gets halted and its context is saved.

CONTEXT SWITCH FROM PROCESS


TO PROCESS
process Po operating system process P,
interrupt or system call
executing
save state into PCB
Idle

reload stale from PCB,

idie
interrupt or syslem call execuing

save stale into PCB,

reload state from PCB


execuling
THREADS
"Athread is a path of execution within a Benefits of Multithreads:
procesSs. " Responsiveness
"Aprocess can contain multiple threads. Resource Sharing
"A thread is a basic unit of CPUutilization; " Economy
it comprises a thread ID, a progran
counter (PC), aregister set, and a stack. Stability
"It shares with other threads belonging to
the same process its code section, data
section, and other operating-system
resources, such as open files and signals.
" Atraditional process has a single thread of
control. If a process has multiple threads
of control, it can perform more than one
task at a time
ProcesS Thread
Program in execution It is the part of process
It isheavy weight process It is light weight prOcess
Process context switch takes more time Thread context switch takes less time

Newprocess creation, termination takes New Thread creation, termination takes


more time lesse time

Each prOcess executes the same code but Allthread can share same set of open files,
has its own memory ad file resources child process

In process based implementation if one Inmultithreaded server implementation, if


process is blocked, no other server process one thread blocked and waiting, second
canexecute until the first process unblocked thread in the same process could execute

Multiple redundant process use more Multiple threaded process use fewer
resources resources
User Level thread Kernel LevelThresd

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

Implementation is by a thread library at the Operating system supports creation of


user level Kernel threads

User level thread is generic and can run on Kernel level thread is specific to the
any operating system operating system

Multi-threaded application cannot take Kernel routines themselves can be


advantage of multiprocessing multithreaded.
Process Scheduling
The objective of nultiprogramming is to have some process running at all times.
Tomaximize the CPUutilization scheduling is done among various processes.
DJob queue- set of all processes in the system
I
0 Ready queue set of all processes residing in main memory, ready and waiting to
execute

o Aready queue header contains pointer to first & last PCBs in the linked list.
o Each PCB has pointer, points to next process in queue.
ODevice queues - set of processes waiting for an IOdevice
-Processes migrate among the various queues
Long term scheduler Short term scheduler Medium term
Scheduler

Selects the process Chooses the process Swaps in andout the


from the disk and from ready queue and process from memory
loads them into main assigns it to CPU
memory for execution,
puts in ready queue

Speed is less Speed is fast Speed is moderate

Transition of process Transition of process No process state


from New to Ready from Ready to transtition
wtihituttsttittttu

executing

Not present in time Minimal in Time Present in Time


sharing system sharingsystem sharing system
Supply a reasonable Select a new process Process are swapped
mix of jobs, such as i/0 to allocate to CPU in and out for
bound and CPUbound frequently balanced process mix
TYPES OF SCHEDULING
NON PREEMPTIVE
"Simple to implemnent.
" No timers, process gets the CPU for as long as desired
"Open to denial-of-service.
" Malicious or buggy process can refuse to yield
" Typically includes an explicit yield system call or similar, plus implicit
yields, ë.g.. performing IO, waiting
PREEMIPTIVE
"Solves denial-of-service.
OS can simply preempt long-running process
"More complex to implement: Timer management, concurrency issues

Types of Scheduling algorithm


" First Come First Server(FCES)
" Shortest Job First (SJF)
"Priority Scheduling
"Round Robin Scheduling
" Multilevel Queue Schedul1ng
" Multilevel Feedback Queue Scheduling
DATE

Arvivaltme = Tine at whic h process enter Ready queue


Pureto
Burs tir : tne equtred by procers to get exected.

Compleanti prouess ndete its ereetion

Campleion tine- Arival tm


Waibing tre : Tuonarount ine- Bngt tme
for Waiting trmee - Total wai ting - No.of milleecomds - Arival tine
preent
time Process eecuteot

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy