Docsity

Shadow Homework Solutions on CS241 System Programming: Networking Problems and Solutions, Assignments of Computer Science

Toggle sidebar
bg1
Shadow Homework on Networking
(Solutions)
CS241 System Programming
Instructor Klara Nahrstedt
Posted May 1, 2006
1. When a procedure is scooped from one machine and placed on another to be
called by RPC (Remote Procedure Call), some problems can occur such as
pointer, unknown array sizes, unknown parameter types and global variables. An
issue not discussed in the class is what happens if the (remote) procedure executes
a system call. What problems might that cause and what might be done to handle
them?
Solution: Clearly the wrong thing happens if a system call is executed
remotely. Trying to read a file on the remote machine will not work if the file
is not there. Also, setting an alarm on the remote machine will not send a
signal back to the calling machine. One way to handle remote system calls is
to trap them and send them back to the originating site for execution.
2. What is a zombie child in parent-server strategy? What happens if in the
following pseudo-code (see below) the server parent does not periodically wait
for its zombie child?
For (; ;) {
Wait for a client request on the listening file descriptor
Create a private two-way communication channel to the client
Fork a child to handle the client
Close file descriptor for the private communication channel
Clean up zombie children }
Solution: Exercise 18.5 in R&R (page 616)
3. What happens if the client name does not fit in the buffer passed to u_accept?
Solution: Exercise 18.10 in R&R (page 622)
4. Consider the program 18.1 in R&R. Suppose we try to make a bidirectional serial
server from this program by declaring an integer variable called child and
replacing the following line bytecopied = copyfile(STDIN_FILENO,
communfd) with the replacement code
if ((child = fork()) == -1) {
perror(“failed to fork a child”); return 1; }
if (child == 0)
bytecopied = copyfile(STDIB_FILENO, communfd);
pf2

Partial preview of the text

Download Shadow Homework Solutions on CS241 System Programming: Networking Problems and Solutions and more Assignments Computer Science in PDF only on Docsity!

Shadow Homework on Networking

(Solutions)

CS241 System Programming Instructor Klara Nahrstedt Posted May 1, 2006

  1. When a procedure is scooped from one machine and placed on another to be called by RPC (Remote Procedure Call), some problems can occur such as pointer, unknown array sizes, unknown parameter types and global variables. An issue not discussed in the class is what happens if the (remote) procedure executes a system call. What problems might that cause and what might be done to handle them?

Solution: Clearly the wrong thing happens if a system call is executed remotely. Trying to read a file on the remote machine will not work if the file is not there. Also, setting an alarm on the remote machine will not send a signal back to the calling machine. One way to handle remote system calls is to trap them and send them back to the originating site for execution.

  1. What is a zombie child in parent-server strategy? What happens if in the following pseudo-code (see below) the server parent does not periodically wait for its zombie child?

For (; ;) { Wait for a client request on the listening file descriptor Create a private two-way communication channel to the client Fork a child to handle the client Close file descriptor for the private communication channel Clean up zombie children }

Solution: Exercise 18.5 in R&R (page 616)

  1. What happens if the client name does not fit in the buffer passed to u_accept?

Solution: Exercise 18.10 in R&R (page 622)

  1. Consider the program 18.1 in R&R. Suppose we try to make a bidirectional serial server from this program by declaring an integer variable called child and replacing the following line bytecopied = copyfile(STDIN_FILENO, communfd) with the replacement code

if ((child = fork()) == -1) { perror(“failed to fork a child”); return 1; } if (child == 0) bytecopied = copyfile(STDIB_FILENO, communfd);

else bytecopied = copyfile(communfd, SDTOUT_FILENO);

What happens if we do this replacement?

Solution: Exercise 18.17 in R&R (page 627)

  1. Consider the program 20.2 in R&R. What happens if you start this program without starting the corresponding server?

Solution: Exercise 20.4 in R&R (page 700)

  1. Draw a timing diagram that illustrates a scenario in which the server receives a client request and then crashes before processing the request.

Solution: Exercise 20.7 in R&R (page 701)