Homework 12 Solved, at last

22C:116, Fall 1999

Douglas W. Jones

  1. Here is a series of experiments that could be incorporated into a program to determine the following characteristics of /dev/hdb:

  2. Part A What prevents the given model from being used in Amoeba? The fact that the "get request" and "put reply" primitives in Amoeba must be in the same thread. The given code handled the request in the main thread and did the reply in a different thread.

    On page 606, in the second to the last paragraph, it says that get request and put reply must be strictly paired. Two consecutive get request operations are forbidden. The only reasonable way to enforce this is to limit each thread to one RPC at a time, adding a state word to the status of each thread what request it is currently processing. If NIL, the thread is not processing a request. If non-NULL, the word points to the header buffer of the request currently being processed. Get request is only legal when this pointer is NULL, and it sets this pointer. Put reply is only legal if the header pointer matches this pointer, and it resets this pointer.

    Part B The following alternate code has an appropriate population limit and conforms to the restriction inferred above:

    	fork N threads, each running the following code
    	  repeat
    	    wait( get request semaphore )
    	    get request
    	    signal( get request semaphore )
    	    process transaction
    	    put reply
              forever
    
    Here, we used the get request semaphore to guarantee that only one thread at a time will wait for an incoming RPC. This may be unnecessary, but it doesn't hurt, and it gives exactly the same mutual exclusion as we had with a single thread doing all get-requests.
  3. A Problem There are several similarities between the use of capabilities in Amoeba and Demos, but This list is not exhaustive.