Part B: It is desirable to include a completely different definition of the type semaphore in the header file than is included with the C source code so that the user of the header file is isolated from all details of the implementation of semaphores. This problem was hard for some students because they assumed that the header file threads.h should have been included in threads.c; in fact, many "fixed" threads.c to correct this "error" and then found that the suggested alternative definition of the semaphore data type lead to a compile time! In fact, the omission of an include file for threads.h in the file threads.c was deliberate!
Part C: No answer given!
There are two possible buddies of a block of size n at address a:
There are two possible buddies of a block of size n at address a:
The virtual address has the following format:
19 13 |__________________|____________| page number thing in pageI have deliberately avoided mention of the nature of the addressed object by using the term "thing in page". The machine could have a word-addressable memory with 8K words per page, or it could have a byte-addressable memory with 8K bytes per page, or it could have a bit addressable memory with 8K bits per page. None of the answer depends on this!
This implies that there are 219 or about 0.5 million pages per address space. If the entire page table is copied from memory to the MMU at the start of each timeslice, 0.5 million entries must be copied. If it takes 100 nanoseconds to copy each entry, the time to copy the entire map will be 50 milliseconds. If we make a new copy every 100 milliseconds, we must spend 50 percent of the CPU time making these copies!