Sie sind auf Seite 1von 20

Programming Project #1 Remote Procedure Call

Due Friday, March 28, 6:00 PM

CS-4513 D-term 2008

Project #1

Programming Assignment
Write a command called rpcdoit to execute another command remotely and print out statistics

Write a service called doitservice to execute commands requested by rpcdoit Develop an RPC interface between them
CS-4513 D-term 2008 Project #1 2

Background
doit an early project of OS course

Takes command and arguments Forks a child process to execute command Waits for child to terminate Gets statistics about child using getrusage() Prints statistics on stdout

CS-4513 D-term 2008

Project #1

This Project
Like doit, but command executes remotely
rpcdoit [-verbose] server command args

This does:
Binds to server Package up command and arguments Makes RPC call to server, waits for results Prints output of command (at least first three lines) Prints statistics
Including round-trip wall clock time, RPC overhead
CS-4513 D-term 2008 Project #1 4

Your task
Design an RPC interface between client and server
.x file suitable for rpcgen

Build client and service programs


rpcdoit, the client doitservice, the service Makefile to build stubs, client, and server

Test
Locally, remotely, concurrently

Write up and submit via web-based Turnin


CS-4513 D-term 2008 Project #1 5

RPC interface
Defines data types, functions, arguments, result One function doit Arguments
argv, argc

Results
struct containing execution statistics

Return code from command Command output (stdout, stderr)


CS-4513 D-term 2008 Project #1 6

rpcgen
Takes .x file containing interface definition
Sun XDR format

Generates
.h files needed by client and server

Client and server stubs (Optional) prototypes for client and server programs

See man and info pages On-line documentation


http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATI ON/HTML/AA-Q0R5B-TET1_html/TITLE.html
CS-4513 D-term 2008 Project #1 7

doitservice
Start with template (prototype) generated by
rpcgen

Register with portmapper


Program number 0x3fzzzzzz Where zzzzzz are last digits of student ID

The remote doit function:


Fork process Execute the command with its arguments (in child process) Waits for result Gets statistics Returns information to caller
Project #1 8

CS-4513 D-term 2008

rpcdoit
Binds to client with clnt_create() Gets wall-clock time Calls the remote function Receives results Gets wall-clock time again Formats and prints
Output of command (at least three lines) Statistics Round-trip execution time (and difference from remote execution time)
CS-4513 D-term 2008 Project #1 9

Work environment
Please do this work on your virtual machine You may use C or C++ Note:
Your programs will probably be compatible with other Linux systems on campus However, not all C/C++ compilers and Linux kernels are alike Some may produce or ignore various warnings Your virtual machine is the one that counts
CS-4513 D-term 2008 Project #1 10

Testing
Run client and service on same (guest) OS
I.e., specify own IP address as service identity

Program and use -verbose switch


Print out calls, arguments, actions, times rpcdoit and doitservice

Start doitservice first


Use portmapping commands to see that it is registered, etc.

Run rpcdoit to execute command


CS-4513 D-term 2008 Project #1 11

Testing (continued)
Once it runs on your own virtual machine branch out and run remotely! Options
Two or more virtual machines SSH to Fossil server and run rpcdoit there, specifying your guest OS IP address
CS-4513 D-term 2008 Project #1 12

Testing (continued more)


Test multiple concurrent callers
From multiple shell windows in client machine

Be sure that remote command takes long enough to ensure concurrency


Verify with verbose output

CS-4513 D-term 2008

Project #1

13

Extra Credit
Figure out and implement how to print the full output of remotely executed command with rpcdoit
Prior to printing out statistics

CS-4513 D-term 2008

Project #1

14

Individual and Class Project


Individual
Each student submits own programs, written in own words, etc. No copies, paraphrases, etc.

Class
Collaborative learning about RPC, XDR, rpcgen, etc. Share your questions! Talk to everyone about the concepts Share your knowledge! Use class e-mail list
CS-4513 D-term 2008 Project #1 15

Project submission
Due Friday, March 28, 6:00 PM Submit via web-based Turnin
Project name = Project 1

Put your name at top of every file!


(You would be surprised how many students forget!)

CS-4513 D-term 2008

Project #1

16

Project Submission (continued)


Code of your solution
.x file for interface .h files generated by rpcgen .c files for rpcdoit and doitservice

One Makefile
make make make make clean all rpcgen doitservice

Test cases Write-up explaining everything


MS Word or PDF
CS-4513 D-term 2008 Project #1 17

Project Submission (continued)


DO NOT
Put different parts of projects in folders Zip files together Create different Makefiles for different parts

Do not make us figure out how to run your programs

CS-4513 D-term 2008

Project #1

18

Grading
Twenty point project Point allocation
See handout Interface is of grade Concurrent execution of multiple calls is of grade

No credit if it fails to build


Will make good-faith attempt to contact you by email to fix

Extra credit
Five points for printing entire command output.
CS-4513 D-term 2008 Project #1 19

Questions?

CS-4513 D-term 2008

Project #1

20

Das könnte Ihnen auch gefallen