Assignment 3, due Feb. 6

Part of the homework for 22C:112, Spring 2009
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

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!

  1. Background: The Unix fork mechanism assumes that each process has its own address space, so that a forked process can be created by duplicating the memory of the original.

    Consider a system whith no memory protection, where all memory could be addressed by any process, with no restrictions. Obviously this system would be insecure, but ignore that.

    a) When a process is forked, would it be necessary to copy the code? In answering this, you may find it useful to consider each type of address that might be embedded in the code. (0.5 points)

    b) When a process is forked, what kind of relocation is required? Assume that the stack contains local variables and return addresses, assume that there are local variables that point to linked lists, trees etc. For simplicity, you can assume that each process has its own heap for allocation of dynamic data structures. Do not worry about feasibility, worry hear about what would be needed. (0.5 points)

    c) Now, discuss what information the operating system would need to fork a process. (0.5 points)

  2. Background: Consider trying to design a better program launching mechanism than the exec() services of Unix. Specifically, focus on the goal of a general parameter passing mechanism. Our goal is to eliminate the odd idea that the parameters to the main program must be text strings, as described by argv and argc in the C/Unix model. Ideally, what we want is the ability to pass any mix of data types to a main program, just as we can do so within a program.

    Suppose we wanted to write a main program that looked like main( int a; char b; widget c) We cannot just call newexec( myprogram, a, b, c), where a, b and c have the appropriate types, because newexec() does not know the types of these parameters.

    a) First, we need a way to specify the parameters in the calling environment. We will need to call our new newexec() service with a parameter list that describe the parameters to be passed. Suggest appropriate parameters for newexec() to describe these parameters. (0.5 points)

    b) Second, we need a way for the called program to check that the parameters passed were the right type. If the result is that the called program does not look like main( int a; char b; widget c), as we had hoped, do not be too worried so long as it is possible, in theory, to translate such a high-level specification of the main program interface into your new scheme. (0.5 points)

    c) Finally, consider the consequence of this for the command language. The Unix model of an array of strings made it fairly easy to write a shell. Suggest how the syntax of a shell might allow specification of parameters of a variety of types. (0.5 points)