0% found this document useful (0 votes)
65 views21 pages

CS3451 - Introduction To Operating Systems: Ii Year / Iv Semester

Uploaded by

revicse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views21 pages

CS3451 - Introduction To Operating Systems: Ii Year / Iv Semester

Uploaded by

revicse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

ARASU ENGINEERING

COLLEGE
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

CS3451 – INTRODUCTION TO
OPERATING SYSTEMS
II YEAR / IV SEMESTER
Anna University Syllabus, 2021
Regulation
Prepared by
Mrs. V. Revathy
Assistant
Professor/ CSE
Multiprocess Architecture: Chrome Browser
 Many web browsers ran as single process (some still do)
 If one web site causes trouble, entire browser can hang or
crash
 Google Chrome Browser is multiprocess with 3 different types
of processes:
 Browser process manages user interface, disk and network
I/O
 Renderer process renders web pages, deals with HTML,
Javascript. A new renderer created for each website
opened
 Runs in sandbox restricting disk and network I/O,
minimizing effect of security exploits
 Plug-in process for each type of plug-in
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
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 models of IPC
 Shared memory
 Message passing
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Communications Models
(a) Message passing. (b) shared
memory.

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


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

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Producer-Consumer Problem
 Paradigm for Bounded-Buffer –
cooperating
processes, producer Shared- Memory
process produces Solution
informatio that  Shared data
consumed
n by a is #define BUFFER_SIZE 10
consumer typedef struct {
process ...
 unbounded-buffer
places no } item;
limit practical
the bufferthe size of
on item buffer[BUFFER_SIZE];
 bounded-buffer int in = 0;
assumes that there is int out = 0;
a fixed buffer size  Solution is correct, but can
only use
CS3451-IOS/
BUFFER_SIZE-1 elements
V. REVATHY / AP-CSE /AEC
Bounded Buffer:Producer & Consumer

item next_produced; item


while (true) { next_consumed;
/ * produce an item in while (true) {
next produced * / while (in == out)
while (((in + 1) % ; / * do nothing * /
BUFFER_SIZE) == next_consumed =
out) buffer[out];
; / * do nothing * / out = (out + 1) %
buffer[in] = next_produced; BUFFER_SIZE;
in = (in + 1) %
/ * consume the item in
BUFFER_SIZE;
next consumed * /
} CS3451-IOS/ V. REVATHY / AP-CSE /AEC
}
Interprocess Communication:Shared
Memory
An area of memory shared among the processes
that wish to communicate
The communication is under the control of the
users processes not the operating system.
Major issues is to provide mechanism that will
allow the user processes to synchronize their
actions when they access shared memory.
Synchronization is discussed in great details in
next topic.

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Interprocess Communication:Message
Passing
 Mechanism for processes to communicate and to synchronize
their actions
 Message system – processes communicate with each other
without resorting to shared variables
 IPC facility provides two operations:
 send(message)
 receive(message)
 The message size is either fixed or variable
 If processes P and Q wish to communicate, they need to:
 Establish a communication link between them
 Exchange messages via send/receive

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Message Passing (Cont.)
 Implementation issues:
 How are links established?
 Can a link be associated with more than two processes?
 How many links can there be between every pair
of communicating processes?
 What is the capacity of a link?
 Is the size of a message that the link can
accommodate fixed or
variable?
 Is a link unidirectional or bi-directional?
 Implementation of communication link
 Physical: Shared memory, Hardware bus &
Network
 Logical: Direct or indirect,
CS3451-IOS/ V. REVATHYSynchronous
/ AP-CSE /AEC or
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 communication
link
Links are established automatically
A link is associated with exactly one
pair of communicating processes
Between each pair there exists exactly one link
The link may be unidirectional, but is
usually bi- CS3451-IOS/
directionalV. REVATHY / AP-CSE /AEC
Indirect Communication
 Messages are directed and received from mailboxes ( ports)
 Each mailbox has a unique id
 Processes can communicate only if they share a mailbox
 Properties of communication link
 Link established only if processes share a common mailbox
 A link may be associated with many processes
 Each pair of processes may share several communication
links
 Link may be unidirectional or bi-directional
 Operations
 create a new mailbox (port)
 send and receive messages through mailbox
 destroy a mailbox
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Indirect
 Primitives are defined as:

Communication
send(A, message) – send a message to mailbox A
 receive(A, message) – receive a message from mailbox A
 Mailbox sharing
 P1, P2, and P3share mailbox A
 P1, sends; P2and P3 receive
 Who gets the message?
 Solutions
 Allow a link to be associated with at most two processes
 Allow only one process at a time to execute a receive
operation
 Allow the system to select arbitrarily the receiver.
Sender is
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
notified who the receiver was.
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 & continue
 Non-blocking receive -- the receiver receives:
 A valid message, or Null message
 Different combinations possible
 If both send and receive are blocking, we have a rendezvous
Producer-consumer becomes trivial
message next_produced;
while (true) {
send(next_produced); /*
produce
} an item in next
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 (rendezvous)
2. Bounded capacity – finite length of n
messages Sender must wait if link full
3. Unbounded capacity – infinite
length Sender never waits

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Examples of IPC Systems - POSIX
POSIX Shared Memory
Process first creates shared memory segment
shm_fd = shm_open(name, O CREAT | O RDWR,
0666);
 Also used to open an existing segment to share it
Set the size of the object
 ftruncate(shm fd, 4096);
Now the process could write to the shared memory
 sprintf(shared memory, "Writing to shared
memory");

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Examples of IPC Systems - Mach
 Mach communication is message based
 Even system calls are messages
 Each task gets two mailboxes at creation- Kernel and Notify
 Only three system calls needed for message transfer
 msg_send(), msg_receive(), msg_rpc()
 Mailboxes needed for commuication, created via
 port_allocate()
 Send and receive are flexible, for ex. four options if mailbox
full:
 Wait indefinitely
 Wait at most n milliseconds
 Return immediately
 Temporarily cache a message
CS3451-IOS/ V. REVATHY / AP-CSE /AEC
Examples of IPC Systems – Windows
 Message-passing centric via advanced local procedure call
(LPC)
facility
 Only works between processes on the same system
 Uses ports (like mailboxes) to establish and
maintain
communication channels
 Communication works as follows:
 The client opens a handle to the subsystem’s connection port
object.
 The client sends a connection request.
 The server creates two private communication
ports and
returns the handle to one of them to the client.
The client CS3451-IOS/and
V. REVATHY / AP-CSE /AEC
serveruse the corresponding port
Local Procedure Calls in Windows

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Communications in Client/Server
System
Sockets
Remote Procedure Calls
Pipes
Remote Method Invocation
(Java)

CS3451-IOS/ V. REVATHY / AP-CSE /AEC


Thank You
CS3451-IOS/ V. REVATHY / AP-CSE /AEC

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