OS6 - Solutions Manual !!!!!!!!!!!!!
120 pág.

OS6 - Solutions Manual !!!!!!!!!!!!!

DisciplinaSistemas Operacionais I8.353 materiais171.771 seguidores
Pré-visualização31 páginas
on any system on the network), heterogeneous system support.
B.2 Name two ways that port sets are useful in implementing parallel programs.
Answer: Many threads or tasks may operate on a given problem, possibly on multiple
CPUs, and communicate with the controlling thread or task via a port set. Each cooperating
thread would have its own destination port in the controlling task. Computations can be
dispatched to each thread and the controlling task can send new computations to each
thread as it returns values through its port. The controlling task can wait for messages
through its port set rather than polling each individual port to see if a computing thread
has finished its job.
B.3 Consider an application that maintains a database of information, and provides facilities
for other tasks to add, delete, and query the database. Give three configurations of ports,
threads, and message types that could be used to implement this system. Which is the
best? Explain your answer.
112 Appendix B The Mach System
\ufffd 1 thread with 1 port, receiving messages of type \u201cquery,\u201d \u201cadd,\u201d and \u201cdelete.\u201d
\ufffd 3 threads and 3 ports with 1 message type, \u201cdata.\u201d A request type is differentiated by
the port to which it arrives. Each thread has responsibility for 1 port, and thus one
type of operation.
\ufffd 3 threads as above, but 1 port and 3 message types as in the first configuration. The
second solution is probably the most flexible, especially if the database is expected to
be very busy (many requests per second). The first is fine for a low-use database.
B.4 Give the outline of a task that would migrate subtasks (tasks it creates) to other systems.
Include information about how it would decide when to migrate tasks, which tasks to
migrate, and how the migration would take place.
Answer: Unfortunately, Mach does not provide all the features needed to directly sup-
port process migration. An outline of an indirect solution follows, and assumes that the
processes to be migrated are all identical.
a. Start the main process.
b. Use the 4.3BSD remote execution facility (the rsh command) to spawn daemons on
every computer to which tasks are to be migrated.
c. Each of these daemons registers itself with the NetMsgServer so the controlling pro-
cess is able to communicate with them.
d. The controlling process then computes the current number of runnable processes (the
load average) on each computer by querying each of the daemons for the load average
on their systems. If the load averages vary noticeably, a task should be migrated.
e. A task is selected based on the time it has had to execute. It is most efficient to migrate
the most-recently-created or least-run-time-accumulated process.
f. A task is migrated by killing it on its system and sending a message to the daemon
on the least-loaded system with enough information to start an identical process ex-
B.5 Name two types of applications for which you would use the MIG package.
Answer: Any program that needs to send or receive messages.
B.6 Why would someone use the low-level system calls, instead of the C Threads package?
Answer: To access facilities outside the range of the C Threads package or to use the facil-
ities in a different way. For instance, port sets are not directly supported by the C Threads
package. Low-level applications, like debuggers, need more direct access to system calls
B.7 Why are external memory managers not able to replace the internal page-replacement
algorithms? What information would need to be made available to the external managers
for the latter to make page-replacement decisions? Why would providing this information
violate the principle behind the external managers?
Answer: If an external memory manager crashes, the system must be able to remove
pages from memory. Without the internal page-replacement algorithms, the system would
starve for memory. Also, the internal routines have access to data that external ones can\u2019t
reach, so, for instance, LRU page replacement can only be implemented by the internal
routine. Data needed outside of the kernel includes page access counts or times and page
Answers to Exercises 113
valid bits. External managers must be system independent. For instance, it might provide
pages to tasks on incompatible CPUs. How would the page table information be provided
in a system-independent way?
B.8 Why is it difficult to implement mutual exclusion and condition variables in an environ-
ment where like CPUs do not share any memory? What approach and mechanism could
be used to make such features available on a NORMA system?
Answer: The best mutual-exclusion algorithms depend on access to shared variables.
These routines become much more difficult to implement and prove correct if, for instance,
all locking negotiation must be done via messages. To implement locking, messages might
be sent to a daemon on a lock server that would allocate locks, report values of locked
variables, and otherwise simulate the behavior of the usual mutex routines.
B.9 What are the advantages to rewriting the 4.3BSD code as an external, user-level library,
rather than leaving it as part of the Mach kernel? Are there any disadvantages? Explain
your answer.
Answer: The kernel is much smaller and efficient. This small kernel can be implemented
on less powerful systems. It should also be more robust since the simpler the kernel,
the fewer bugs it should have. Also, since the kernel is locked into physical memory, the
smaller it is the less memory is needed on the machines on which it runs. The disadvantage
is that the system as a whole becomes more complicated, with BSD code spread out among
libraries, a little kernel-level code, and code in each user process. It is also difficult to
implement correctly, to keep such facilities as BSD signals working.