Why, in the example thread manager, was it necessary to have two distinct
functions, thread_manager_init and thread_manager_start?
Inspect the thread data structure thread and the implementation of
the thread_relinquish operation, and compare these to the suggested
process table fields given in Figure 2-4 of the text and the context
switching operation given in Figure 2-5 of the text. Explain the major
differences!
Propose a set of data structures that would allow implementation of semaphores
under the example thread manager; these should make maximal use of the types
already declared in the source code for the thread manager.
Consider the following little UNIX program using parallel processes:
main()
{
int i;
i = 0;
if (fork()) {
int j;
for (j = 0;j < 1000; j++) { i++; }
wait();
} else {
int j;
for (j = 0;j < 1000; j++) { i--; }
exit();
}
printf( "%d\n", i );
}
What output did this program produce? Explain why the output is not zero!