SlidePub
Home
Categories
Login
Register
Home
Education
Unit 2 chapter notes for the student1-1.ppt
Unit 2 chapter notes for the student1-1.ppt
Rajasekhar364622
26 views
43 slides
Oct 14, 2024
Slide
1
of 43
Previous
Next
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
About This Presentation
study document
Size:
680.21 KB
Language:
en
Added:
Oct 14, 2024
Slides:
43 pages
Slide Content
Slide 1
Silberschatz, Galvin and Gagne ©2013Operating System Concepts Essentials – 2
nd
Edition
UNIT 2 Chapter 1: Processes
Slide 2
3.2 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
UNIT 2 Chapter 1: Processes
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication
Communication in Client-Server Systems
Slide 3
3.3 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Objectives
To introduce the notion of a process -- a program in
execution, which forms the basis of all computation
To describe the various features of processes, including
scheduling, creation and termination, and communication
To explore interprocess communication using shared memory
and message passing
To describe communication in client-server systems
Slide 4
3.4 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Concept
Textbook uses the terms job and process almost interchangeably
Process – a program in execution; process execution must
progress in sequential fashion
Multiple parts
Text section is also called as program code section which stores
instructions of the program.
program counter is a processor register which contains
address of next instruction to be executed.
Data section containing global variables and static variables.
Heap section contains dynamically memory allocated
variables.
Stack is also called as function stack which is used for storing
function parameters, local variables or temporary variables,
return variables.
Slide 5
3.5 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process in Memory
Slide 6
3.6 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Concept (Cont.)
Program is passive entity stored on disk (executable file),
process is active
Program becomes process when executable file loaded into
memory
Execution of program started via GUI mouse clicks, command
line entry of its name, etc
One program can be several processes
Consider multiple users executing the same program
Slide 7
3.7 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process State transition diagram
As a process executes, it changes state
new: when ever a process is created then it is in new state.
ready: ready state contains a list of processes which are ready
for execution. The process is waiting to be assigned to a
processor. scheduler picks one process from ready state and
allocate it to the CPU.
running: running state contains the process that is currently
being executed by CPU.
a)When CPU receives interrupt, then the currently running
process will be moved to ready state.
b)If currently executing process needs an I/O operation
then that process will be moved to waiting state.
waiting: The process is waiting for some I/O operation. If I/O
operation completed, then that process will be moved to ready
state.
terminated: The process has finished execution
Slide 8
3.8 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
process state transition diagram
Slide 9
3.9 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Control Block (PCB)
A process is represented in OS using
PCB.
Every process has its own PCB.
Information associated with each
process (also called task control
block)
The PCB is used by operating system
to manage information about a running
process.
Process state – The state may be new,
ready, running, waiting, terminated or
halted.
Process number:- A unique
identification number assigned to each
process in the system. This allows the
OS to distinguish between different
processes.
Slide 10
3.10 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Control Block (PCB)
Program counter – The address of the
next instruction to be executed .
CPU registers – used for storing the
data. CPU uses Different registers like
Program counter, Instruction register,
Accumulator, Index register, Base
register, limit register, PSW(program
status word)
CPU scheduling information-
Parameters related to process
scheduling like priority levels,
scheduling queues, and time-related
information.
Memory-management information –
This information includes values of
base register, limit register, page table,
segmentation table.
Slide 11
3.11 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Control Block (PCB)
Accounting Information:- This
information includes the amount of CPU
time used, and other metrics that can
be useful for performance analysis.
I/O status information:- This information
includes list of I/O devices allocated to
the process, a list of open files.
Slide 12
3.12 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Context Switch
Switching the CPU from one process to another process is
known as context switching.
When CPU switches from one process to another process, the
Operating system must save the state of the old process and
load the saved state for the new process via a context switch
Context of a process represented in the PCB
Context-switch time is overhead; the CPU does no useful work
while switching
The more complex the OS and the PCB the longer the
context switch
Slide 13
3.13 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
CPU Switch From Process to Process
Slide 14
3.14 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Scheduling
The objective of multiprogramming is to have some process
always running, 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 Process scheduler decides the order
in which the processes are to be executed.
Process scheduler Maintains scheduling queues of processes
Job queue –It contains set of all processes in the system
Ready queue – It contains a list of processes which are
ready for execution. The process is waiting to be assigned to
a processor. scheduler picks one process from ready queue
and allocate it to the CPU. This queue is generally stored as
a linked list.
Device queues or I/O queues – set of processes waiting for
I/O Operations.
Processes migrate among the various queues
Slide 15
3.15 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Representation of Process Scheduling
Queueing diagram represents queues, resources, flows
Slide 16
3.16 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Schedulers
Short-term scheduler (or CPU scheduler) – selects which process should
be executed next and allocates CPU
Sometimes the only scheduler in a system
Short-term scheduler is invoked frequently (milliseconds) (must be
fast)
Long-term scheduler (or job scheduler) – Loads a process from
secondary memory to main memory i.e., it selects which processes should
be brought into the ready queue
Long-term scheduler is invoked infrequently (seconds, minutes) (may
be slow)
The long-term scheduler controls the degree of multiprogramming
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
Long-term scheduler strives for good process mix
Slide 17
3.17 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Medium Term Scheduling
Medium-term scheduler can be added if degree of multiple
programming needs to decrease
Remove process from memory, store on disk, bring back in
from disk to continue execution: swapping
Slide 18
3.18 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Operations on Processes
System must provide mechanisms for:
process creation,
process termination
Slide 19
3.19 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Creation
Parent process create children processes, which, in turn
create other processes, forming a tree of processes
Generally, process identified and managed via a process
identifier (pid)
Resource sharing options
Parent and children share all resources
Children share subset of parent’s resources
Parent and child share no resources
Execution options
Parent and children execute concurrently
Parent waits until children terminate
Slide 20
3.20 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
A Tree of Processes in Linux
Slide 21
3.21 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Creation (Cont.)
Address space of child process
Child duplicate of parent
Child has a new process loaded into it
UNIX examples
fork() system call creates new process
exec() system call used after a fork() to replace the
process’ memory space with a new program
Slide 22
3.22 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
C Program Forking Separate Process
Slide 23
3.23 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Process Termination
Process executes last statement and then asks the operating
system to delete it using the exit() system call.
Parent may terminate the execution of children processes using
the abort() system call. Some reasons for doing so:
Child has exceeded allocated resources
Task assigned to child is no longer required
Some operating systems do not allow child to exists if its parent
has terminated . If a process terminates, then all its children must
also be terminated i.e., cascading termination. All children,
grandchildren, etc. are terminated.
The termination is initiated by the operating system.
. .
Slide 24
3.24 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Interprocess Communication
Processes within a system may be independent or cooperating
Cooperating process can affect or be affected by other processes,
including sharing data
Reasons for cooperating processes:
Information sharing
Computation speedup
Modularity
Convenience
Cooperating processes need interprocess communication (IPC)
Two mechanisms or models to implement IPC
Shared memory
Message passing
Slide 25
3.25 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Cooperating Processes
Independent process cannot affect or be affected by the execution
of another process
Cooperating process can affect or be affected by the execution of
another process
Advantages of process cooperation
Information sharing
Computation speed-up
Modularity
Convenience
Slide 26
3.26 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Communications Models
(a) Message passing. (b) shared memory.
Slide 27
3.27 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
SHARED MEMORY
The best example for shared memory is producer – consumer problem.
Paradigm for cooperating processes, producer process produces
information that is consumed by a consumer process
unbounded-buffer places no practical limit on the size of the buffer
bounded-buffer assumes that there is a fixed buffer size
Slide 28
3.28 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Bounded-Buffer – Shared-Memory Solution
Shared data
#define BUFFER_SIZE 10
typedef struct {
. . .
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
Solution is correct, but can only use BUFFER_SIZE-1 elements
in specifies next free position
out specifies first full position
Slide 29
3.29 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Bounded-Buffer – Producer
item next_produced;
while (true) {
/* produce an item in next produced */
while (((in + 1) % BUFFER_SIZE) == out) ; /* do nothing */
buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
}
Slide 30
3.30 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Bounded Buffer – Consumer
item next_consumed;
while (true) {
while (in == out) ; /* do nothing */
next_consumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
/* consume the item in next consumed */
}
Slide 31
3.31 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Interprocess Communication – Message Passing
3 ISSUES
1.Naming
a. Direct Communication
b. Indirect Communication
2. Synchronization
a. Blocking Sender and Receiver
b. Non-Blocking Sender and Non-Blocking Receiver
3. Buffering
a. Zero capacity
b. Bounded or finite capacity
c. unbounded or infinite capacity
Slide 32
3.32 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Naming - 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
Slide 33
3.33 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Indirect Communication
Messages are directed and received from mailboxes (also referred
to as ports)
Each mailbox has a unique id
Processes can communicate only if they share a mailbox
Operations
create a new mailbox (port)
send and receive messages through mailbox
destroy a mailbox
Primitives are defined as:
send(A, message) – send a message to mailbox A
receive(A, message) – receive a message from mailbox A
Slide 34
3.34 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Synchronization
Message passing may be either blocking or non-blocking
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
continue
Non-blocking receive -- the receiver receives:
A valid message, or
Null message
Slide 35
3.35 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Buffering
Queue of messages 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
2.Bounded capacity – finite length of n messages
Sender must wait if link full
3.Unbounded capacity – infinite length
Sender never waits
Slide 36
3.36 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Communications in Client-Server Systems
Client sends a request to server; server process the request
and delivers a response to the client.
Client – Server communication is done in 3 ways.
1. Sockets
2. Remote Procedure Calls (RPC)
3. Pipes
Slide 37
3.37 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Sockets
Sockets are useful for communication between 2 processes
Socket is a Concatenation of IP address and port
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
Special IP address 127.0.0.1 (loopback) to refer to system on
which process is running
FTP port no is 21, Telnet port no is 23, HTTP port no is 80.
Slide 38
3.38 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Socket Communication
Slide 39
3.39 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Remote Procedure Calls
Calling a procedure located at remote systems.
Client calls client-side proxy or client stub for the actual
procedure on the server.
Client stub locates the server and packs parameters into a
message, and this is called marshalling.
Client sends message to the server using system call.
Server calls server stub or server proxy.
server stub receives this message, unpacks the marshalled
parameters, and executes the procedure on the server
Slide 40
3.40 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Pipes
Pipes also used to communicate between 2 processes.
Ordinary pipes – Ordinary pipes are unidirectional
communication channels between two related processes,
typically a parent and its child process..
Named pipes – Named pipes are also communication
channels, but they are bidirectional and can be used for
communication between unrelated processes.
Slide 41
3.41 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Ordinary Pipes
Ordinary Pipes allow communication in standard producer-consumer
style
Producer writes to one end (the write-end of the pipe)
Consumer reads from the other end (the read-end of the pipe)
Ordinary pipes are therefore unidirectional
Require parent-child relationship between communicating processes
Slide 42
3.42 Silberschatz, Galvin and Gagne ©2013
Operating System Concepts Essentials – 2
nd
Edition
Named Pipes
Named Pipes are more powerful than ordinary pipes
Communication is bidirectional
No parent-child relationship is necessary between the
communicating processes
Several processes can use the named pipe for communication
Provided on both UNIX and Windows systems
Slide 43
Silberschatz, Galvin and Gagne ©2013Operating System Concepts Essentials – 2
nd
Edition
End of Chapter 1
Tags
Categories
Education
Download
Download Slideshow
Get the original presentation file
Quick Actions
Embed
Share
Save
Print
Full
Report
Statistics
Views
26
Slides
43
Age
414 days
Related Slideshows
11
TLE-9-Prepare-Salad-and-Dressing.pptxkkk
MaAngelicaCanceran
32 views
12
LESSON 1 ABOUT MEDIA AND INFORMATION.pptx
JojitGueta
24 views
60
GRADE-8-AQUACULTURE-WEEKQ1.pdfdfawgwyrsewru
MaAngelicaCanceran
40 views
26
Feelings PP Game FOR CHILDREN IN ELEMENTARY SCHOOL.pptx
KaistaGlow
39 views
54
Jeopardy_Figures_of_Speech_Template.pptx [Autosaved].pptx
acecamero20
23 views
7
Jeopardy_Figures_of_Speech.pptxvdsvdsvsdvsd
acecamero20
24 views
View More in This Category
Embed Slideshow
Dimensions
Width (px)
Height (px)
Start Page
Which slide to start from (1-43)
Options
Auto-play slides
Show controls
Embed Code
Copy Code
Share Slideshow
Share on Social Media
Share on Facebook
Share on Twitter
Share on LinkedIn
Share via Email
Or copy link
Copy
Report Content
Reason for reporting
*
Select a reason...
Inappropriate content
Copyright violation
Spam or misleading
Offensive or hateful
Privacy violation
Other
Slide number
Leave blank if it applies to the entire slideshow
Additional details
*
Help us understand the problem better