Docsity

System Programming Intercrosses Communication - Lecture Slides | CS 241, Study notes of Computer Science

Partial preview of the text

Download System Programming Intercrosses Communication - Lecture Slides | CS 241 and more Study notes Computer Science in PDF only on Docsity!

CS241 System Programming

Interprocess Communication (VII)

Klara Nahrstedt Lecture 40 4/28/

Contents

z

Communication Paradigms – Putting it Together

z

Remote Procedure Call

z

Performance Issues – Things to be aware off

Interprocess CommunicationParadigms within a Single Machine z

Pipes

Pipe command creates a communication butter that twoprocesses (Parent and Child) can use to access viafildes[0] to read from and fildes[1] to write to.

z

Shared memory

Shmid – shared memory segment is attached to the callingprocess

Shmget, Shmat assist in creating the shared memorysegment and attaching it to the calling process

Read/write assist in communicating via shared memory

z

Message Queues

Msqid – major data structure for message queue is needed

Msgget, msgsnd, msgrsv assist in creating the messagequeue and communicating via message queue

Connection-Oriented CommunicationParadigm for Client-Server Interaction

TCP

TCP

Network

ProgramLogic forServer Process

Program Logic for Client Process

Connection-less CommunicationParadigm between Two DifferentMachines

u_openudp(p)

u_openudp(p)

u_sendtohost()

close

u_recvfrom()

UICI UDP Server

UICI UDP Client

create UDP endpointbound to port p

Create unbound UDPendpoint

Wait for request

send request

process requestresume waiting

close endpoint

request message

u_sendto()

send response

reply message

u_recvfrom()

wait for response

UDP

UDP Protocol

Network

rogram ogic or Server rocess

ProgramLogicFor ClientProcess

Connection-less CommunicationParadigms between Two DifferentMachines z

No connection setup

z

Datagram messages are being exchanged

z

Since no connection exists, each message musthave in its send/recv message the source anddestination information.

z

Underlying UDP protocol provides only a forwardingmechanism, nothing else

z

If the application processes want more reliability, butwant to run on top of the UDP protocol, they mustprovide this capability themselves via ‘request-reply’protocol or ‘request-reply-acknowledgement’protocols

Remote Procedure Call (2)

Implementation Issues z

Cannot pass pointers

call by reference becomes copy-restore (but might fail)

z

Weakly typed languages

client stub cannot determine size

z

Not always possible to determine parameter types

z

Cannot use global variables

may get moved to remote machine

Remote Procedure Call (3)

z

Parameters of RPC are marshaled into message inthe RPC client process

z

Message sent and local RPC process waits

z

Remote machine receives RPC message, spawnsremote process that will execute the remotecomputation on behave of the user client

z

Remote process assumes same protection domainas local process

RPC Semantics (5)

z

at most once

z

at least once

z

once

z

idempotent

Application of RPC

Thin Client Machine

Server Machine TCP

Network

TCP

Disk

Display

RPC ClientProcess

RPC ServerProcess

User I/OProcess

IPC

Client Stub

Server Stub

Performance Issues when ExchangingMessages between Clients and Servers

z

Synchronous or asynchronous

z

Loss, Timeouts, Acknowledgments,Sequence numbers

z

Congestion

Synchronous or Asynchronous

z

Synchronous

Process waits for message – Rendezvous

Process waits for message to be received

z

Asynchronous

Pool of messages with query mechanism toretrieve a message

Processes send messages without delay

Processes receive messages from pool

Naming

z

Authentication

Who is the message from?

Who gets the message?

z

Ports

Send to a Port ID – any server process can receive.

z

Process IDs – only one process receives

Other Performance Issues

z

How many times is a message copied before itsdelivered?

z

Loss of cache by receiving message

z

Wait time for synchronous/asynchronous messages

z

Search time for asynchronous messages

z

How do network functions impact messagepassing/exchange

Network Model – Topology

Routing

Contention