Assignment 12, due May 1
Part of
the homework for 22C:112, Spring 2009
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!
See man 2 dup for mechanisms permitting open files to be moved to a different descriptor number, and note that if an open file is visible from two descriptor numbers, close() applied to one of its numbers does not close access to the file through the other number.
A problem: Give a fragment of C code that launches two applications using execve(), call them "app1" and "app2", where standard output of "app1" is piped into standard input of "app2", while both applications remain able to read and write the other files that were open prior to your code fragment. Your fragment should wait for both child processes to terminate before it exits. (1.0 points)
A problem: Write the code for a server that implements a single semaphore, with initial (abstract) value zero and client-to-server messages "P" and "V" corresponding to the wait and signal operations (names chosen in part because they are of length 1). You may assume pre-existing library implementations of such things as stacks and queues with the usual operations. (1.0 points)
In Amoeba and Demos, many resources that are statically accessible in systems modeled on Unix are, instead, passed in what can be thought of as analogous to the environment in Unix. Among the most important of these is the file system.
a) What system data structure holds the envoronment of a Demos process? (0.5 points)
b) What system data structure in Unix (or Linux) is analogous to the data structure you identified in part a. Note that this Unix data structure has a far narrower use than the use it has in Demos. (0.5 points)