Assignment 10, due Nov 8

Part of the homework for 22C:116, fall 2002
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

  1. Background: Here is a specification for a Demos-like model of interprocess communication that can be implemented under our example thread manager:
    s = send( dst, buf, len );
    send to dst (of type link) the contents of the buffer buf (of type void*) with a length in bytes of len (of type int). Variables of type link may be directly included in the buffer. This blocks until the message has been delivered and returns the number of bytes actually copied to the receiver. If dst is an invalid link

    s = receive( queuetab, number, buf, len );
    receive a message from the indicated queue number (an integer) in the queue table queuetab (of type queuetable*) into the buffer buf (of type void*) with a length in bytes of len (of type int). This blocks until a message has been delivered and returns the number of bytes actually copied from the sender.

    number = queueselect( queuetab, numbers, len );
    given numbers (of type int*), an array of len (of type int) integers, each interpreted as a queue number, and given queuetab (of type queurtable*), block until one of the queues indexed in numbers contains a message, and return the queue number. If more than one of the queues mentioned in numbers contains a message, the number returned may refer to any one of them.

    queuetab = newqueuetable( slots );
    allocate a queue table with a capacity of slots queues (an integer), returning a pointer to that table in queuetab (of type queuetable*). All the queues in the table are initially empty.

    link = newlink( queuetab, number );
    return a link allowing sending of messages to the indicated queue number (an integer) in the indicated queue table.

    Note that this set of primitives doesn't require the use of a link table because we allow links to be stored intermixed with normal variables. Note also that the queue table is not necessarily implemented as an array of queues! It is an abstraction which may have additional complexity.

    Part A: If it were not for the queueselect service, there would be many ways to implement this set of primitives. Therefore, you must begin your implementation by working out a feasible implementation for queueselect, using semaphore operations for synchronization, plus whatever other data structures are required to make it work. Propose a solution.

    Part B: Give the header file that gives the interface specification for this package. This should conform to the style guidelines referenced from the class web page, and it need not attempt to hide the implementation of the data structures from the reader.

    Notice: The complete implementation of these functions will be assigned in next week's homework.

  2. A problem: The set of primitives outlined in the previous problem is at the session level in the ISO OSI protocol hierarchy! Why?

  3. A problem: The notes for lecture 26 contains an algorithm for synchronizing one clock to another. This algorithm ignores the results of any query of the remote clock that takes more than mintriptime time units, but mintriptime is not a constant! Under what circumstances does it decrease, under what circumstances does it increase, and most of important of all, why?

  4. A problem: Consider the use of a synchronization agent, as outlined in lecture 27. What if the agent is an interrupt service routine (or alternately, a signal handler). In this case, the agent can't wait on a semaphore for the user to do something. Taking into account the synchronization between agent and application required by these distributed mutual exclusion algorithms, explain how you would handle the agent-application synchronization in this case.