WhiteBoard Project using C RPC
A Project in Distributed Computing at IIIT-Delhi
|
Please read DIC Projects first. This 0README
is a supplement to the lectures. It describes a bit of the philosophy behind the course and some details of the source code given to you as a start.
This course expects that you are already comfortable in the use of networked machines based on Linux/Unix and X11. Learn to login to remote machines via ssh without having to interactively type your password each time; read 2350/ NetworkLab #ssh
Students whose Linux OS programming skills are rusty should study examples for {alarm, fork, pipes, signals, bash
scripting} much simpler than what you see in our project files. At WSU, we expect CEG 4350/6350 OS Internals and Design to have taught these. Recommended book: W. Richard Stevens and Stephen A. Rago, Advanced Programming in the Unix Environment, Addison-Wesley, ISBN: 0-201-56317-7. http://www.apuebook.com/
Some of you worry this is C and not C++. C is a subset of C++. Also, the code does use lower-than-what-is-typical-in-C++ libraries. One of the goals of this course: Expose you to the basics of systems programming relevant to distributed computing. If you know C++ well enough, you should be able to fully understand C. Some quick equiv C v C++: malloc/free
v new/delete
mem allocation; static
v private
scope; static
v static
life time; e1? e2 : e3
v e1? e2 : e3
conditional expression;
RPC background is not expected. Several of the RPC lib procedures will be discussed in class. On Linux, these have become part of C std lib; on other OS you may have to explicitly give -lrpcsvc
to the linker (ld
of gcc
or g++
).
We will go over this in the lectures.
Expand the tar ball of source code 7370-WB-C-RPC-2014.tbz
using tar xvvfj 7370-WB-C-RPC-2014.tbz
It is expected that you will study the source code closely. It is only 800+ lines. You should become so familiar with it as if you wrote it. The only exception is xwindow.c; just read the comments.
The source code as given is ready to be built using make
. There should be no compilation/link warnings except possibly in rpcgen
-erated code. It should also run without any glitches. If these are not working out (i) in the OSIS Lab, report problems to me, (ii) on Linux systems elsewhere, I may be able to help, but there is too much ground to cover. Below %
is my bash prompt as a non-root user.
The following are the "original" (i.e., created by a human programmer) files.
rpcgen server.x
generates server.h server_xdr.c server_clnt.c server_svc.c
rpcgen client.x
generates client.h client_xdr.c client_clnt.c client_svc.c
client_s.c
is a minor variation of client_svc.c
mechanically produced by running an editor script on client_svc.c
. We insert startclient(...)
just above the svcrun()
line.xwindow.c
can be compiled as a stand-alone program xwindow7370
to check for X11 problems.static int i
within procedures; such an i
is not allocated on the stack. This makes i
"stay/live" even after that procedure returns.-Wall -ansi -pedantic -std=c99
on; read-up on what these do. There should be zero errors/ warnings. The rpcgen
generated code unfortunately is not as kosher. Note also that non-Linux OS may have ancient rpcgens that generate even worse code so far as these flags are concerned.alarm
, fork
, pipe
s, and signal
s. Our (simple minded) use of signals requires -D_BSD_SIGNALS.
% make
will compile the source code file deregall.c
into a program named deregall7370
. This can de-register transient RPC processes.% make clean
.% make tar
Some of you may wish to use your own Linux boxes for 7370 work. But Linux installations out-of-the-box are typically not "open" enough for us. Check your Linux Setup first.
192.168.17.*
export DISPLAY=H2:0.0
% server7370 &
% client7370 <srv-mchn-nm> <wb-nm> <wb-disp> <color>=\\ =<srv-mchn-nm>
is the name of the machine running your server; <wb-nm>
is the name of the whiteboard you wish to create/join; <wb-disp>
is the name of the machine you are logged in for the X11 display; <color>
is a 6-hex-digit X11 RGB color number for lines of this client;Here are a few bash procedures: A simple "smoke test" with all the processes running on localhost
and kill all and deregister 7370 related processes. Read man killall
and man pkill
.
Locate where rpcinfo
is. Perhaps it is in /usr/sbin
instead of /usr/bin
. Read its man page. Here is an example invocation on Linux machines:
Do the above after a fresh reboot. This shows the presence of other standard RPC processes. After you "close" your WB project demo, the list then should be the same.
backtrace()
; it will offset the time you may otherwise waste in debugging. http://www.gnu.org/software/libc/manual/html_node/Backtraces.html% ldd client7370 server7370