0% found this document useful (0 votes)
7 views

Week 3b

Os Notes
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)
7 views

Week 3b

Os Notes
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/ 13

Lecture 3b

OPERATING SYSTEMS
wait() & fork() Example

2
wait() & fork() Example

Save the file with .cpp


extension

Run the file through


these commands
3
Mailboxes
 A mailbox may be owned either by the process or the operating system.

Process mailbox
 If it is owned by a process, there is an owner ( which receives messages) and
a user (which sends messages).
 Each mailbox has a unique owner – no confusion
 When the process terminates, the mailbox disappears.

System mailbox
 If the mailbox is owned by the operating system, it is independent and not
attached to a process.
 The operating system must provide a mechanism to allow a process to:
 Create a new mailbox
 Send and receive messages through the mailbox
 Delete a mailbox
Synchronization
 Message passing may be either blocking or non-blocking
 Blocking is considered synchronous
 Blocking send has the sender block until the message is
received
 Blocking receive has the receiver block until a message is
available
 Non-blocking is considered asynchronous
 Non-blocking send has the sender send the message and
continue
 Non-blocking receive has the receiver receive a valid message
or null
Communications in Client-Server Systems

 Sockets
 Remote Procedure Calls
 Pipes
 Remote Method Invocation (Java)

Operating System Concepts – 9th Edition 3.6 Silberschatz, Galvin and Gagne ©2013
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 and server use the corresponding port handle to
send messages or callbacks and to listen for replies.
Local Procedure Calls in Windows

Operating System Concepts – 9th Edition 3.8 Silberschatz, Galvin and Gagne ©2013
Socket Communication

• A socket is defined as an endpoint


for communication
• The socket 161.25.19.8:1625
refers to port 1625 on host
161.25.19.8
• Communication consists between a
pair of sockets
• Special IP address refer to system
on which process is running

Operating System Concepts – 9th Edition 3.9 Silberschatz, Galvin and Gagne ©2013
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
 Remote communication has more failure scenarios than
local
 Messages can be delivered exactly once rather than
at most once

Operating System Concepts – 9th Edition 3.10 Silberschatz, Galvin and Gagne ©2013
Execution of RPC

Operating System Concepts – 9th Edition 3.11 Silberschatz, Galvin and Gagne ©2013
Pipes
 Pipes are a type of IPC (Inter-Process Communication)
technique that allows two or more processes to communicate
with each other by creating a unidirectional or bidirectional
channel between them.
 A pipe is a virtual communication channel that allows data to be
transferred between processes, either one-way or two-way.
 Pipes can be implemented using system calls in most modern
operating systems, including Linux, macOS, and Windows

 Ordinary pipes – cannot be accessed from outside the


process that created it. Typically, a parent process creates
a pipe and uses it to communicate with a child process that
it created.
 Named pipes – can be accessed without a parent-child
relationship.

Operating System Concepts – 9th Edition 3.12 Silberschatz, Galvin and Gagne ©2013
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

 Windows calls these anonymous pipes

Operating System Concepts – 9th Edition 3.13 Silberschatz, Galvin and Gagne ©2013

You might also like