SlideShare una empresa de Scribd logo
1 de 52
Descargar para leer sin conexión
Processes
Chapter 3:
 Process Concept
 Process Scheduling
 Operations on Processes
 Interprocess Communication
 Examples of IPC Systems
 Communication in Client-Server Systems
 A process is a program in execution. It is the unit
of work in most system
 Process execution must progress in sequential
fashion.
 Process includes:-
 Current activity, as represented by the value of the
program counter and contents of the processor's
registers,
 Process stack, which contains temporary data (such
as function parameters, return addresses, and local
variables), and
 Data section, which contains global variables
 A process may also include a heap, which is
memory that is dynamically allocated during
process run time.
 Program is passive entity, process is active
 Program becomes process when executable file
loaded into memory
 Process is an active entity, with a program
counter specifying the next instruction to
execute and a set of associated resources.
 Execution of program started via GUI mouse
clicks or command line entry of its name, etc
Process in memory
Process State
 As a process executes, it changes state
 The state of a process is defined in part by the
current activity of that process.
 A process may be in one of the following 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.
Diagram of process state
 It is important to realize that only one process
can be running on any processor at any instant
 However, many processes may be ready and
waiting.
Process Control Block
 Each process is represented in the operating system
by a process control block (PCB)—also called a
task control block.
 The PCB is a data structure.
 It is used as the repository for any information that
may vary from process to process.
 It contains many pieces of information associated
with a specific process, including these: Process
state, Program counter, CPU registers, CPU-
scheduling information, Memory-management
information, Accounting information, I/O status
information.
 Process state: The state may
be new, ready, running, waiting,
halted, and so on.
 Program counter:The counter
indicates the address of the
next instruction to be executed for
this process.
 CPU registers. They include
accumulators, index registers, stack
pointers, and general-purpose
registers, plus any condition-code
information
 CPU-scheduling information:- This
information includes a process priority,
pointers to scheduling queues, and any
other scheduling parameters.
 Memory-management information:- This
information may include such items as
the value of the base and limit registers
and the page tables, or the segment
tables, depending on the memory system
used by the operating system
 Accounting information. This information
includes the amount of CPU and real
time used, time limits, account
numbers, job or process numbers, and
so on.
 I/O status information. This information
includes the list of I/O devices allocated
to the process, a list of open files, and so
on.
Process Scheduling
 The objective of multiprogramming is, to maximize
CPU utilization.
 The objective of time sharing is to switch the CPU
among processes so frequently that users can
interact with each program while it is running.
 To meet these objectives, the process scheduler
selects an available process for program execution
on the CPU.
 For a single-processor system, there will never be
more than one running process. If there are more
processes, the rest will have to wait until the CPU is
free and can be rescheduled
Scheduling Queues
 If there are more processes, the rest will
have to wait in a job queue until the
CPU is free.
 The processes that are ready and
waiting to execute are kept on a list
called the ready queue.
 The queue is generally stored as a
linked list.
 The queue header contains pointers to
the first and last PCBs in that list.
Queueing diagram
 A common representation of
process scheduling is a
queueing diagram
 Each rectangular box
represents a queue. Two types
of queues are present: the
ready queue and a set of
device queues
 The circles represent the
resources that serve the
queues, and the arrows indicate
the flow of processes in the
system
 Once the process is allocated the CPU and is
executing, one of several events could occur:
 The process could issue an I/O request and then be
placed in an I/O queue.
 The process could create a new child process and
wait for the child’s termination.
 The process could be removed forcibly from the
CPU, as a result of an interrupt, and be put back in
the ready queue.
 In the first two cases, the process eventually
switches from the waiting state to the ready
state and is then put back in the ready queue
Scheduling levels
 A process migrates among the various
scheduling queues throughout its life time.
The selection process is carried out by the
appropriate scheduler.
 Long-term scheduler (LTS)
 The long-term scheduler, or job scheduler,
selects processes from the pool and loads
them into memory for execution.
 The long-term scheduler executes much less
frequently; minutes may separate the creation
of one new process and the next.
 The long-term scheduler controls the
degree of multiprogramming (the number
of processes in memory)
 Processes can be described as either:
 I/O-bound process
 Spends more time doing I/O than
computations, many short CPU bursts
 CPU-bound process
 Spends more time doing computations; few
very long CPU bursts
 Short-term scheduler (STS)
 The short-term scheduler, or CPU scheduler,
selects from among the processes that are
ready to execute and allocates the CPU to one of
them.
 The short-term scheduler must select a new
process for the CPU frequently. A process
may execute for only a few milliseconds
before waiting for an I/O request.
 Often, the short-term scheduler executes at
least once every 100 milliseconds
 Medium term scheduler(MTS)
 Time-sharing systems, may introduce an
additional, intermediate level of scheduling.
Medium-term scheduler removes processes
from memory and thus reduces the degree of
multiprogramming.
 Later, the process can be reintroduced into
memory, and its execution can be continued
where it left off. This scheme is called
swapping. The process is swapped out, and is
later swapped in, by the medium-term
scheduler.
Context Switch
 Switching the CPU to another process requires
performing a state save of the current process
and a state restore of a different process. This
task is known as a context switch
 When CPU switches to another process,
the system must:
1. save the state of the old process, and
2. load the saved state for the new process
CPU Switch From Process to Process
Operations on Processes
 The processes in most systems can
execute concurrently, and they may be
created and deleted dynamically. Thus,
these systems must provide a mechanism
for process creation and termination.
Process Creation
 A process may create several new processes,
via a create-process system call, during the
course of execution. The creating process is
called a parent process, and the new
processes are called the children of that
process.
 When a process creates a new process, two
possibilities exist in terms of execution:
a)The parent continues to execute concurrently with
its children.
b) The parent waits until some or all of its children
have terminated
 There are also two possibilities in terms of
the address space of the new process:
a) The child process is a duplicate of the parent
process (has the same program and it data as
the parent).
b) The child process has a new program
loaded into it
 UNIX examples
 fork() system call creates new process
 Child is a copy of parent’s address space
A Tree of Processes in Linux
init
pid = 1
sshd
pid = 3028
login
pid = 8415
kthreadd
pid = 2
sshd
pid = 3610
pdflush
pid = 200
khelper
pid = 6
tcsch
pid = 4005
emacs
pid = 9204
bash
pid = 8416
ps
pid = 9298
Process Termination
 A process terminates when it finishes executing its
final statement and asks the operating system to
delete it or by another process via an appropriate
system call.
 A parent may terminate the execution of one of its
children for a variety of reasons, such as these:
 The child has exceeded its usage of some of the
resources that it has been allocated.
 The task assigned to the child is no longer
required.
 The parent is exiting, and the operating system
does not allow a child to continue if its parent
terminates
 Some systems do not allow a child to exist if its
parent has terminated.
 In such systems, if a process terminates (either
normally or abnormally), then all its children
must also be terminated. This is referred to as
cascading termination.
 The parent process may wait for termination of a
child process
 If no parent waiting (did not invoke wait()) process
is a zombie
 If parent terminated without waiting the
child , process is an orphan
Interprocess Communication
 Processes executing concurrently in the
operating system may be either independent
processes or cooperating processes.
 A process is independent if it cannot affect or
be affected by the other processes executing in
the system. Independent process does not share
data with any other process.
 A process is cooperating if it can affect or be
affected by the other processes executing in the
system. Process that shares data with other
processes is a cooperating process
 There are several reasons for providing an
environment that allows process cooperation:
 Information sharing:- Since several users may
be interested in the same piece of information (for
instance, a shared file), we must provide an
environment to allow concurrent access to such
information.
 Computation speedup:- If we want a particular
task to run faster, we must break it into subtasks,
each of which will be executing in parallel with the
others. Notice that such a speedup can be achieved
only if the computer has multiple processing cores.
 Modularity:- constructing the system in a
modular fashion, dividing the system
functions into separate processes or
threads
 Convenience:- an individual user may
work on many tasks at the same time. For
instance, a user may be editing, listening
to music, and compiling in parallel.
 Cooperating processes require an inter
process communication(IPC) mechanism that
will allow them to exchange data and
information.
 There are two fundamental models of inter
process communication:
 Shared memory and
 Message passing.
 In the shared-memory model, a region of memory that
is shared by cooperating processes is established.
Processes can then exchange information by reading
and writing data to the shared region.
 In the message-passing model,
communication takes place by means of
messages exchanged between the cooperating
processes.
Shared Memory
 An area of memory is shared among the
processes that wish to communicate
 The communication is under the control of
the users processes, not the OS.
 Major issue is to provide mechanism that
will allow the user processes to
synchronize their actions when they access
shared memory.
 The code for accessing and manipulating the
shared memory be written explicitly by the
application programmer.
Producer-Consumer Problem
 A common paradigm for cooperating processes.
 A producer process produces information that
is consumed by a consumer process.
 For example, a compiler may produce
assembly code that is consumed by an
assembler. And also server as a producer and
a client as a consumer
 One solution to the producer–consumer problem
uses shared memory.
 To allow producer and consumer processes to
run concurrently, we must have available a
buffer of items that can be filled by the producer
and emptied by the consumer
 The producer and consumer must be
synchronized, so that the consumer does not
try to consume an item that has not yet been
produced.
 Two types of buffers can be used
 Unbounded Buffer
 Bounded Buffer
Message Passing
 Message passing provides a mechanism to
allow processes to communicate and to
synchronize their actions without sharing the
same address space
 It is particularly useful in a distributed
environment.
 A message-passing facility provides at least two
operations:
 send(message)
 receive(message)
 Messages sent by a process can be either fixed
or variable in size
 If processes P and Q wish to communicate, they
need to:
 Establish a communication link between
them
 Exchange messages via send/receive
 Logical implementation of communication link
 Direct or indirect
 Synchronous or asynchronous
 Automatic or explicit buffering
 Processes that want to communicate must have
a way to refer to each other. They can use either
direct or indirect communication.
Direct communication
 Processes must name each other explicitly:
 send (P, message) – send a message to process P
 receive(Q, message) – receive a message from
process Q
 Properties of a direct communication link
 Links are established automatically
 A link is associated with exactly two
processes communicating
 Between each pair of processes, there exists
exactly one link.
Indirect Communication
 The messages are sent to and received from
mailboxes, or ports
 A mailbox can be viewed as an object into
which messages can be placed by processes
and from which messages can be removed.
 Each mailbox has a unique identification.
 Two processes can communicate only if they
have a shared mailbox
 send(A,message)—Send a message to mailbox A.
 receive(A, message)—Receive a message from
mailbox A.
Properties of communication link :
 A link is established between a pair of processes only if
both members of the pair have a shared mailbox.
 A link may be associated with more than two processes.
 Between each pair of communicating processes, a
number of different links may exist, with each link
corresponding to one mailbox
 Operations
 create a new mailbox (port)
 send and receive messages through mailbox
 destroy a mailbox
Synchronization
 Communication between processes takes
place through calls to send() and receive()
primitives.
 There are different design options for
implementing each primitive. Message
passing may be either blocking or
nonblocking
 Blocking is considered synchronous
 Blocking send -- the sender is blocked until
the message is received
 Blocking receive -- the receiver is blocked
until a message is available
 Non-blocking is considered asynchronous
 Non-blocking send -- the sender sends the
message and continues
 Non-blocking receive -- the receiver receives:
 A valid message, or
 Null message
Buffering
 Queue of messages is attached to the link.
 Implemented in one of three ways
1. Zero capacity – no messages are queued on
a link.
- Sender must wait for receiver (rendezvous)
2. Bounded capacity – finite length of n
messages
- Sender must wait if link full
3. Unbounded capacity – infinite length
- Sender never waits
Examples of IPC Systems – Windows
 The message-passing facility in Windows is
called the advanced local procedure call(ALPC)
facility
 It is used for communication between two
processes on the same machine.
 It is similar to the standard remote procedure
call (RPC) mechanism that is widely used, but it
is optimized for and specific to Windows.
 Uses ports (like mailboxes) to establish and
maintain communication channels
Communications In Client-server
Systems
 Sockets
 Remote Procedure Calls
Sockets
 A socket is defined as an endpoint for communication
 A socket is identified by concatenation of IP address
and port – a number included at start of message
packet to differentiate network services on a host
 The socket 161.25.19.8:1625 refers to port 1625 on host
161.25.19.8
 Communication consists between a pair of sockets
 All ports below 1024 are well known, used for
standard services. Eg. a telnet server listens to port
23; an FTP server listens to port 21; and a web, or
HTTP, server listens to port 80
 Special IP address 127.0.0.1 (loopback) to refer to
system on which process is running
Sockets
 When a client process initiates a request
for a connection, it is assigned a port by its
host computer.
 This port has some arbitrary number greater
than 1024. For example, if a client on host X
with IP address 146.86.5.20 wishes to establish
a connection with a web server (which is
listening on port 80) at address 161.25.19.8,
host X may be assigned port 1625. The
connection will consist of a pair of sockets:
(146.86.5.20:1625) on host X and
(161.25.19.8:80) on the web server
Socket Communication
Sockets in Java
 In Java there are three types of sockets
 Connection-oriented (TCP) implemented
with the Socket class.
 Connectionless (UDP) use the Datagram
Socket class
 Multicast Socket class– data can be sent to
multiple recipients (sub-class of UDP)
Remote Procedure Calls
 Remote procedure call (RPC) abstracts
procedure calls between processes on
networked systems
 Again uses ports for service differentiation
 Stubs – client-side proxy for the actual
procedure on the server
 The client-side stub locates the server and
encode (marshal) the parameters
 The server-side stub receives this message,
unpacks the marshalled parameters, and
performs the procedure on the server
Remote Procedure Calls (Cont.)
 Data representation handled via External
Data Representation (XDL) format to
account for different architectures
 Big-endian and little-endian
 Remote communication has more failure
scenarios than local
 Messages can be delivered exactly once
 OS typically provides a matchmaker
service to connect client and server
Execution of RPC

Más contenido relacionado

Similar a Chapter 3.pdf

My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process managementBabasab Patil
 
My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process managementBabasab Patil
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptMohammad Almuiet
 
Chapter two process.pptx
Chapter two process.pptxChapter two process.pptx
Chapter two process.pptxMezigebuMelese1
 
Operating system || Chapter 3: Process
Operating system || Chapter 3: ProcessOperating system || Chapter 3: Process
Operating system || Chapter 3: ProcessAnkonGopalBanik
 
Operating system - Process and its concepts
Operating system - Process and its conceptsOperating system - Process and its concepts
Operating system - Process and its conceptsKaran Thakkar
 
Operating System
Operating SystemOperating System
Operating SystemGowriLatha1
 
OS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of osOS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of osTahaShahid18
 
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationLM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationMani Deepak Choudhry
 
CSI-503 - 3. Process Scheduling
CSI-503 - 3. Process SchedulingCSI-503 - 3. Process Scheduling
CSI-503 - 3. Process Schedulingghayour abbas
 
Operating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxOperating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxAmanuelmergia
 
Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxAmanuelmergia
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdfAmanuelmergia
 

Similar a Chapter 3.pdf (20)

My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process management
 
My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process management
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.ppt
 
Chapter two process.pptx
Chapter two process.pptxChapter two process.pptx
Chapter two process.pptx
 
unit-2.pdf
unit-2.pdfunit-2.pdf
unit-2.pdf
 
Operating system || Chapter 3: Process
Operating system || Chapter 3: ProcessOperating system || Chapter 3: Process
Operating system || Chapter 3: Process
 
Os unit 2
Os unit 2Os unit 2
Os unit 2
 
Operating system - Process and its concepts
Operating system - Process and its conceptsOperating system - Process and its concepts
Operating system - Process and its concepts
 
Operating System
Operating SystemOperating System
Operating System
 
UNIT I-Processes.pptx
UNIT I-Processes.pptxUNIT I-Processes.pptx
UNIT I-Processes.pptx
 
OS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of osOS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of os
 
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationLM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
 
Processing management
Processing managementProcessing management
Processing management
 
CSI-503 - 3. Process Scheduling
CSI-503 - 3. Process SchedulingCSI-503 - 3. Process Scheduling
CSI-503 - 3. Process Scheduling
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
 
Operating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxOperating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptx
 
Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptx
 
Os
OsOs
Os
 
Os
OsOs
Os
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdf
 

Último

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 

Último (20)

ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

Chapter 3.pdf

  • 2.  Process Concept  Process Scheduling  Operations on Processes  Interprocess Communication  Examples of IPC Systems  Communication in Client-Server Systems
  • 3.  A process is a program in execution. It is the unit of work in most system  Process execution must progress in sequential fashion.  Process includes:-  Current activity, as represented by the value of the program counter and contents of the processor's registers,  Process stack, which contains temporary data (such as function parameters, return addresses, and local variables), and  Data section, which contains global variables
  • 4.  A process may also include a heap, which is memory that is dynamically allocated during process run time.  Program is passive entity, process is active  Program becomes process when executable file loaded into memory  Process is an active entity, with a program counter specifying the next instruction to execute and a set of associated resources.  Execution of program started via GUI mouse clicks or command line entry of its name, etc
  • 6. Process State  As a process executes, it changes state  The state of a process is defined in part by the current activity of that process.  A process may be in one of the following 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.
  • 7. Diagram of process state  It is important to realize that only one process can be running on any processor at any instant  However, many processes may be ready and waiting.
  • 8. Process Control Block  Each process is represented in the operating system by a process control block (PCB)—also called a task control block.  The PCB is a data structure.  It is used as the repository for any information that may vary from process to process.  It contains many pieces of information associated with a specific process, including these: Process state, Program counter, CPU registers, CPU- scheduling information, Memory-management information, Accounting information, I/O status information.
  • 9.  Process state: The state may be new, ready, running, waiting, halted, and so on.  Program counter:The counter indicates the address of the next instruction to be executed for this process.  CPU registers. They include accumulators, index registers, stack pointers, and general-purpose registers, plus any condition-code information
  • 10.  CPU-scheduling information:- This information includes a process priority, pointers to scheduling queues, and any other scheduling parameters.  Memory-management information:- This information may include such items as the value of the base and limit registers and the page tables, or the segment tables, depending on the memory system used by the operating system
  • 11.  Accounting information. This information includes the amount of CPU and real time used, time limits, account numbers, job or process numbers, and so on.  I/O status information. This information includes the list of I/O devices allocated to the process, a list of open files, and so on.
  • 12. Process Scheduling  The objective of multiprogramming is, to maximize CPU utilization.  The objective of time sharing is to switch the CPU among processes so frequently that users can interact with each program while it is running.  To meet these objectives, the process scheduler selects an available process for program execution on the CPU.  For a single-processor system, there will never be more than one running process. If there are more processes, the rest will have to wait until the CPU is free and can be rescheduled
  • 13. Scheduling Queues  If there are more processes, the rest will have to wait in a job queue until the CPU is free.  The processes that are ready and waiting to execute are kept on a list called the ready queue.  The queue is generally stored as a linked list.  The queue header contains pointers to the first and last PCBs in that list.
  • 14. Queueing diagram  A common representation of process scheduling is a queueing diagram  Each rectangular box represents a queue. Two types of queues are present: the ready queue and a set of device queues  The circles represent the resources that serve the queues, and the arrows indicate the flow of processes in the system
  • 15.  Once the process is allocated the CPU and is executing, one of several events could occur:  The process could issue an I/O request and then be placed in an I/O queue.  The process could create a new child process and wait for the child’s termination.  The process could be removed forcibly from the CPU, as a result of an interrupt, and be put back in the ready queue.  In the first two cases, the process eventually switches from the waiting state to the ready state and is then put back in the ready queue
  • 16. Scheduling levels  A process migrates among the various scheduling queues throughout its life time. The selection process is carried out by the appropriate scheduler.  Long-term scheduler (LTS)  The long-term scheduler, or job scheduler, selects processes from the pool and loads them into memory for execution.  The long-term scheduler executes much less frequently; minutes may separate the creation of one new process and the next.
  • 17.  The long-term scheduler controls the degree of multiprogramming (the number of processes in memory)  Processes can be described as either:  I/O-bound process  Spends more time doing I/O than computations, many short CPU bursts  CPU-bound process  Spends more time doing computations; few very long CPU bursts
  • 18.  Short-term scheduler (STS)  The short-term scheduler, or CPU scheduler, selects from among the processes that are ready to execute and allocates the CPU to one of them.  The short-term scheduler must select a new process for the CPU frequently. A process may execute for only a few milliseconds before waiting for an I/O request.  Often, the short-term scheduler executes at least once every 100 milliseconds
  • 19.  Medium term scheduler(MTS)  Time-sharing systems, may introduce an additional, intermediate level of scheduling. Medium-term scheduler removes processes from memory and thus reduces the degree of multiprogramming.  Later, the process can be reintroduced into memory, and its execution can be continued where it left off. This scheme is called swapping. The process is swapped out, and is later swapped in, by the medium-term scheduler.
  • 20. Context Switch  Switching the CPU to another process requires performing a state save of the current process and a state restore of a different process. This task is known as a context switch  When CPU switches to another process, the system must: 1. save the state of the old process, and 2. load the saved state for the new process
  • 21. CPU Switch From Process to Process
  • 22. Operations on Processes  The processes in most systems can execute concurrently, and they may be created and deleted dynamically. Thus, these systems must provide a mechanism for process creation and termination.
  • 23. Process Creation  A process may create several new processes, via a create-process system call, during the course of execution. The creating process is called a parent process, and the new processes are called the children of that process.  When a process creates a new process, two possibilities exist in terms of execution: a)The parent continues to execute concurrently with its children. b) The parent waits until some or all of its children have terminated
  • 24.  There are also two possibilities in terms of the address space of the new process: a) The child process is a duplicate of the parent process (has the same program and it data as the parent). b) The child process has a new program loaded into it  UNIX examples  fork() system call creates new process  Child is a copy of parent’s address space
  • 25. A Tree of Processes in Linux init pid = 1 sshd pid = 3028 login pid = 8415 kthreadd pid = 2 sshd pid = 3610 pdflush pid = 200 khelper pid = 6 tcsch pid = 4005 emacs pid = 9204 bash pid = 8416 ps pid = 9298
  • 26. Process Termination  A process terminates when it finishes executing its final statement and asks the operating system to delete it or by another process via an appropriate system call.  A parent may terminate the execution of one of its children for a variety of reasons, such as these:  The child has exceeded its usage of some of the resources that it has been allocated.  The task assigned to the child is no longer required.  The parent is exiting, and the operating system does not allow a child to continue if its parent terminates
  • 27.  Some systems do not allow a child to exist if its parent has terminated.  In such systems, if a process terminates (either normally or abnormally), then all its children must also be terminated. This is referred to as cascading termination.  The parent process may wait for termination of a child process  If no parent waiting (did not invoke wait()) process is a zombie  If parent terminated without waiting the child , process is an orphan
  • 28. Interprocess Communication  Processes executing concurrently in the operating system may be either independent processes or cooperating processes.  A process is independent if it cannot affect or be affected by the other processes executing in the system. Independent process does not share data with any other process.  A process is cooperating if it can affect or be affected by the other processes executing in the system. Process that shares data with other processes is a cooperating process
  • 29.  There are several reasons for providing an environment that allows process cooperation:  Information sharing:- Since several users may be interested in the same piece of information (for instance, a shared file), we must provide an environment to allow concurrent access to such information.  Computation speedup:- If we want a particular task to run faster, we must break it into subtasks, each of which will be executing in parallel with the others. Notice that such a speedup can be achieved only if the computer has multiple processing cores.
  • 30.  Modularity:- constructing the system in a modular fashion, dividing the system functions into separate processes or threads  Convenience:- an individual user may work on many tasks at the same time. For instance, a user may be editing, listening to music, and compiling in parallel.
  • 31.  Cooperating processes require an inter process communication(IPC) mechanism that will allow them to exchange data and information.  There are two fundamental models of inter process communication:  Shared memory and  Message passing.  In the shared-memory model, a region of memory that is shared by cooperating processes is established. Processes can then exchange information by reading and writing data to the shared region.
  • 32.  In the message-passing model, communication takes place by means of messages exchanged between the cooperating processes.
  • 33. Shared Memory  An area of memory is shared among the processes that wish to communicate  The communication is under the control of the users processes, not the OS.  Major issue is to provide mechanism that will allow the user processes to synchronize their actions when they access shared memory.  The code for accessing and manipulating the shared memory be written explicitly by the application programmer.
  • 34. Producer-Consumer Problem  A common paradigm for cooperating processes.  A producer process produces information that is consumed by a consumer process.  For example, a compiler may produce assembly code that is consumed by an assembler. And also server as a producer and a client as a consumer  One solution to the producer–consumer problem uses shared memory.
  • 35.  To allow producer and consumer processes to run concurrently, we must have available a buffer of items that can be filled by the producer and emptied by the consumer  The producer and consumer must be synchronized, so that the consumer does not try to consume an item that has not yet been produced.  Two types of buffers can be used  Unbounded Buffer  Bounded Buffer
  • 36. Message Passing  Message passing provides a mechanism to allow processes to communicate and to synchronize their actions without sharing the same address space  It is particularly useful in a distributed environment.  A message-passing facility provides at least two operations:  send(message)  receive(message)  Messages sent by a process can be either fixed or variable in size
  • 37.  If processes P and Q wish to communicate, they need to:  Establish a communication link between them  Exchange messages via send/receive  Logical implementation of communication link  Direct or indirect  Synchronous or asynchronous  Automatic or explicit buffering  Processes that want to communicate must have a way to refer to each other. They can use either direct or indirect communication.
  • 38. Direct communication  Processes must name each other explicitly:  send (P, message) – send a message to process P  receive(Q, message) – receive a message from process Q  Properties of a direct communication link  Links are established automatically  A link is associated with exactly two processes communicating  Between each pair of processes, there exists exactly one link.
  • 39. Indirect Communication  The messages are sent to and received from mailboxes, or ports  A mailbox can be viewed as an object into which messages can be placed by processes and from which messages can be removed.  Each mailbox has a unique identification.  Two processes can communicate only if they have a shared mailbox  send(A,message)—Send a message to mailbox A.  receive(A, message)—Receive a message from mailbox A.
  • 40. Properties of communication link :  A link is established between a pair of processes only if both members of the pair have a shared mailbox.  A link may be associated with more than two processes.  Between each pair of communicating processes, a number of different links may exist, with each link corresponding to one mailbox  Operations  create a new mailbox (port)  send and receive messages through mailbox  destroy a mailbox
  • 41. Synchronization  Communication between processes takes place through calls to send() and receive() primitives.  There are different design options for implementing each primitive. Message passing may be either blocking or nonblocking
  • 42.  Blocking is considered synchronous  Blocking send -- the sender is blocked until the message is received  Blocking receive -- the receiver is blocked until a message is available  Non-blocking is considered asynchronous  Non-blocking send -- the sender sends the message and continues  Non-blocking receive -- the receiver receives:  A valid message, or  Null message
  • 43. Buffering  Queue of messages is attached to the link.  Implemented in one of three ways 1. Zero capacity – no messages are queued on a link. - Sender must wait for receiver (rendezvous) 2. Bounded capacity – finite length of n messages - Sender must wait if link full 3. Unbounded capacity – infinite length - Sender never waits
  • 44. Examples of IPC Systems – Windows  The message-passing facility in Windows is called the advanced local procedure call(ALPC) facility  It is used for communication between two processes on the same machine.  It is similar to the standard remote procedure call (RPC) mechanism that is widely used, but it is optimized for and specific to Windows.  Uses ports (like mailboxes) to establish and maintain communication channels
  • 45. Communications In Client-server Systems  Sockets  Remote Procedure Calls
  • 46. Sockets  A socket is defined as an endpoint for communication  A socket is identified by concatenation of IP address and port – a number included at start of message packet to differentiate network services on a host  The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8  Communication consists between a pair of sockets  All ports below 1024 are well known, used for standard services. Eg. a telnet server listens to port 23; an FTP server listens to port 21; and a web, or HTTP, server listens to port 80  Special IP address 127.0.0.1 (loopback) to refer to system on which process is running
  • 47. Sockets  When a client process initiates a request for a connection, it is assigned a port by its host computer.  This port has some arbitrary number greater than 1024. For example, if a client on host X with IP address 146.86.5.20 wishes to establish a connection with a web server (which is listening on port 80) at address 161.25.19.8, host X may be assigned port 1625. The connection will consist of a pair of sockets: (146.86.5.20:1625) on host X and (161.25.19.8:80) on the web server
  • 49. Sockets in Java  In Java there are three types of sockets  Connection-oriented (TCP) implemented with the Socket class.  Connectionless (UDP) use the Datagram Socket class  Multicast Socket class– data can be sent to multiple recipients (sub-class of UDP)
  • 50. Remote Procedure Calls  Remote procedure call (RPC) abstracts procedure calls between processes on networked systems  Again uses ports for service differentiation  Stubs – client-side proxy for the actual procedure on the server  The client-side stub locates the server and encode (marshal) the parameters  The server-side stub receives this message, unpacks the marshalled parameters, and performs the procedure on the server
  • 51. Remote Procedure Calls (Cont.)  Data representation handled via External Data Representation (XDL) format to account for different architectures  Big-endian and little-endian  Remote communication has more failure scenarios than local  Messages can be delivered exactly once  OS typically provides a matchmaker service to connect client and server