DOC PREVIEW
FSU COP 5611 - Lecture 6 IP Communications

This preview shows page 1-2-3-4-5-36-37-38-39-40-73-74-75-76-77 out of 77 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 77 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Interprocess Communications Andy Wang COP 5911 Advanced Operating Systems Outline IPC fundamentals UNIX sockets Remote procedural call Shared memory and large memory spaces IPC in Windows NT IPC Fundamentals What is IPC Mechanisms to transfer data between processes Why is it needed Not all important procedures can be easily built in a single process Why do processes communicate To share resources Client server paradigms Inherently distributed applications Reusable software components Other good software engineering reasons The Basic Concept of IPC A sending process needs to communicate data to a receiving process Sender wants to avoid details of receiver s condition Receiver wants to get the data in an organized way IPC from the OS Point of View Private address space Private address space OS address space Process A Process B Fundamental IPC Problem for the OS Each process has a private address space Normally no process can write to another process s space How to get important data from process A to process B OS Solutions to IPC Problem Fundamentally two options 1 Support some form of shared address space Shared memory 2 Use OS mechanisms to transport data from one address space to another Files messages pipes RPC Fundamental Differences in OS Treatment of IPC Solutions Shared memory OS has job of setting it up And perhaps synchronizing But not transporting data Messages etc OS involved in every IPC Os transports data Desirable IPC Characteristics Fast Easy to use Well defined synchronization model Versatile Easy to implement Works remotely IPC and Synchronization Synchronization is a major concern for IPC Allowing sender to indicate when data is transmitted Allowing receiver to know when data is ready Allowing both to know when more IPC is possible IPC and Connections IPC mechanisms can be connectionless or require connection Connectionless IPC mechanisms require no preliminary setup Connection IPC mechanisms require negotiation and setup before data flows Sometimes much is concealed from user though Connectionless IPC Data simply flows Typically no permanent data structures shared in OS by sender and receiver Good for quick short communication less long term OS overhead Less efficient for large frequent communications Each communication takes more OS resources per byte Connection Oriented IPC Sender and receiver pre arrange IPC delivery details OS typically saves IPC related information for them Advantages disadvantages pretty much the opposites of connectionless IPC Basic IPC Mechanisms File system IPC Message based IPC Procedure call IPC Shared memory IPC IPC Through the File System Sender writes to a file Receiver reads from it But when does the receiver do the read Often synchronized with file locking or lock files Special types of files can make file based IPC easier File IPC Diagram Process A Data Process B Message Based IPC Sender formats data into a formal message With some form of address for receiver OS delivers message to receiver s message input queue might signal too Receiver when ready reads a message from the queue Sender might or might not block Message Based IPC Diagram OS Process A Data sent from A to B B s message queue Process B Procedure Call IPC Interprocess communication uses same procedure call interface as intraprocess Data passed as parameters Information returned via return values Complicated since destination procedure is in a different address space Generally calling procedure blocks till call returns File IPC Diagram main call Data as parameters Data as return values server Process A Process B Shared Memory IPC Different processes share a common piece of memory Either physically or virtually Communications via normal reads writes May need semaphores or locks In or associated with the shared memory Shared Memory IPC Diagram main x 10 write variable x x 10 read variable x print x Process A Process B Synchronizing in IPC How do sending and receiving process synchronize their communications Many possibilities Based on which process block when Examples that follow in message context but more generally applicable Blocking Send Blocking Receive Both sender and receiver block Sender blocks till receiver receives Receiver blocks until sender sends Often called message rendezvous Non Blocking Send Blocking Receive Sender issues send can proceed without waiting to discover fate of message Receiver waits for message arrival before proceeding Essentially receiver is message driven Non Blocking Send Non Blocking Receive Neither party blocks Sender proceeds after sending message Receiver works until message arrvies Either receiver periodically checks in nonblocking fashion Or some form of interrupt delivered Addressing in IPC How does the sender specify where the data goes In some cases the mechanism makes it explicit e g shared memory and RPC In others there are options Direct Addressing Sender specifies name of the receiving process Using some form of unique process name Receiver can either specify name of expected sender Or take stuff from anyone Indirect Addressing Data is sent to queues mailboxes or some other form of shared data structure Receiver performs some form of read operations on that structure Much more flexible than direct addressing Duality in IPC Mechanisms Many aspects of IPC mechanisms are duals of each other Which implies that these mechanisms have the same power First recognized in context of messages vs procedure calls At least IPC mechanisms can be simulated by each other So which IPC mechanism to build choose use Depends on model of computation And on philosophy of user In particular cases hardware or existing software may make one perform better Typical UNIX IPC Mechanisms Different versions of UNIX introduced different IPC mechanisms Pipes Message queues Semaphores Shared memory Sockets RPC Pipes Only IPC mechanism in early UNIX systems other than files Uni directional Unformatted Uninterpreted Interprocess byte streams Accessed in file like way Pipe Details One process feeds bytes into pipe A second process reads the bytes from it Potentially blocking communication mechanism Requires close cooperation between processes to set up Named pipes allow more flexibility Pipes and Blocking Writing more bytes than pipe capacity blocks the sender Until the receiver reads some of them Reading bytes when none are available blocks the receiver Until the sender writes some Single pipe can t cause deadlock UNIX Message Queues Introduced in System V


View Full Document

FSU COP 5611 - Lecture 6 IP Communications

Documents in this Course
Load more
Download Lecture 6 IP Communications
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 6 IP Communications and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 6 IP Communications and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?