留学生辅导 CS 563 Concurrent Programming

CS 563 Concurrent Programming
Lecture 9: RPC and Rendezvous

Client-Server Interaction

Copyright By PowCoder代写 加微信 powcoder

Message passing is great for filters and peers
But it is somewhat low level for client-server
Distributed systems make heavy use of client/server interactions
Two additional programming notations
Remote procedure call (RPC) and rendezvous

Client Server
op name(formals)
# in the interface
proc name(formals)
execute in new process
call name(actuals)
.continue on .
A new process (thread is created to service the call)

Rendezvous

Rendezvous
op name(formals)
# in the interface
process server
… wait for call
in name(formals) -> body execute in
call name(actuals)
continue on
Interact with an existing process
existing process continue executing

There is no op queue because
there are never pending calls (assuming there is no limit on new threads)
➡ evaluate args
➡ pack into a message
➡ send to server
➡ receive reply
➡ unpack results into vars
When “call” arrives at server: ➡create a thread
➡the thread does a local call, which eventually sends a reply to the caller

Rendezvous
When “call” arrives at server: ➡put on op queue OR
awaken server
➡server process “receives” from op queue ➡after servicing call, server sends reply to caller
➡ evaluate args
➡ pack into a message
➡ send to server
➡ receive reply
➡ unpack results into vars

RPC Example
Time Server
operations
Module Body
Local Synchronization

Java Remote Method Invocation (RMI)
compile the programs
generate a stub and a skeleton for the server(s) (these handle the implementation described above)
start the registry service
it keeps track of names and creates sockets and such start server on its host
start client on its host
The parts are compiled as if in one program, but they start separately and use the registry server to “connect” with each other

Rendezvous: Basic Primitives
in opname(formals) -> body ni
Provides a “remote subroutine” Multiple entries
in op1(…) ->…
[] op2(…) ->…
Service invocations are in FIFO order

Delay Based on Local State
Synchronization expression (and or st)
in request() and avail>0 -> avail–
[] release() -> avail++; …

Delay Based on Arguments
in getforks(i) and not (eating[i+1] or eating[i-1])
-> eating[i] := true
[] relforks(i) -> eating[i] := false

Scheduling Based on Arguments
Scheduling expression (by)
in request(time) and free by time -> free := false
[] release() -> free := true

Bounded Buffer

Centralized Dining Philosophers

Time Server

SJN Allocator

Priority to an Operation
?opname — number of pending invocations
in op1() -> S1
[] op2() and ?op1 = 0 -> S2 # gives priority to op1

Multiple Primitive Summary

Simple Receive
in opname(formals) -> vars := formals ni
=== receive opname(vars)

Bounded Buffer

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com