PART II CONCURRENCY CONTROL IN MAIN MEMORY
Chapter 9 System Structure
Exercises
9-1 Why is a single process inadequate to implement a dedicated service such as a file server?
In practice it may be necessary to work on several client requests at the same time. A single process would have to implement state saving and restoring on behalf of the clients, as one became blocked for I/O and another was to run.
Why are multiple processes each in a separate address space inconvenient for such an implementation?
Each process needs to access the common filing system data structures.
For what kinds of concurrent system would you expect to use a separate address space for each process?
When they are to run on the same machine: where interaction between processes is not required or is infrequent. Also where there is a requirement for protection between them. When they are to run on different machines they must run in separate address spaces.
To what extent can the memory management techniques studied in Chapter 6 be used to achieve the kind of data sharing that is needed in the implementation of a service?
If the process model of the OS is one process per address space and segmentation is supported, it could be arranged that separate processes each run the file service code but that they are able to share some of their data segments. The problem of which process should respond to which client would also have to be solved. This is essentially a naming problem. How is the filing system named when it is invoked? It might be that an interface process could take all requests and pass them on to free worker processes. A great deal of context switching overhead is involved if each process is to run in a separate address space. A multi-threading arrangement is preferable.
9-2 Consider the file service implementation given in Chapter 7. Which data structures must be accessed on behalf of every client of the service? Which data is private to an individual client? Could the memory management techniques studied in Chapter 6 be used to achieve shared service code, some shared data and some private data? (Consider the programming language storage allocation scheme outlined in Chapter 4. Assume that each process has a separate stack and that they share a heap.)
The shared data structures from the suggested implementation in Chapter 7 are the metadata table, the tables which hold information on open files, a disk block cache and/or buffer pool in main memory. Private data is that which relates to a particular client. In practice, a given file may be open for shared use, typically shared reading but sometimes for co-operative write sharing. Although each process has a private control stack, the bulk of the data structures need to be shared.
9-3 Give examples of interactions between processes that require one-to-one, many-to-one, one-to-many and many-to-many interactions.
For each example other than one-to-one, consider whether you could use a sequence of separate one-to-one interactions or whether you genuinely need an interaction involving many processes simultaneously.
Some examples are given in Section 9.6 to justify the classification.
Many distributed algorithms use a one to many pattern of communication. The distributed mutual exclusion algorithm in the appendix is one example. The two-phase commit and validation protocols of Chapter 20 are others. At this stage the point that a distributed agreement may be required is sufficient. The argument against a succession of one to one communications is the time taken, particularly if each message must receive a reply (acknowledgement) before the next can be sent as might be the case in RPC.
A debugger for a distributed system may wish to halt all processes as quickly as possible when a breakpoint occurs.
Many to one and many to many are set up in the text as naming requirements rather than a requirement for simultaneous communication.
9-4 Give examples of problems that can arise from uncontrolled access by concurrent processes to shared, writeable data.
The example given in the text is that an aeroplane seat, theatre seat, etc. could be double booked.
Another example is a chemical plant controller which is managing the production and packaging of some chemical. A process or processes are monitoring production and incrementing a variable amount. Another process reads amount periodically and when there is sufficient material, arranges for it to be removed for packaging then resets amount to zero and so on. Also, a process reports the value of amount to a management information system periodically. Various interleaving of the actions of the processes can cause errors. Records of small units of production can be lost between a test and clear, for example.