University of Massachusetts, Amherst
COMPSCI 230
COMPSCI 230 Computer Systems Principles B
Final Exam
ANSWER SHEET FOR PROGRAMMING QUESTION
1. 100001101 or 0110011 2. d
3. sem_wait: line 17 and 27 (or 28)
sem_post: line 25 and 30
4. a, c, d
5. 0, 2, 3, 5, 7 6. b, c, e
7.
a b c d e
T N P B T
8. 4
9. b 10. A’s: 4, B’s: 2
11. a, b 12. 4
...[Show More]
COMPSCI 230 Computer Systems Principles B
Final Exam
ANSWER SHEET FOR PROGRAMMING QUESTION
1. 100001101 or 0110011 2. d
3. sem_wait: line 17 and 27 (or 28)
sem_post: line 25 and 30
4. a, c, d
5. 0, 2, 3, 5, 7 6. b, c, e
7.
a b c d e
T N P B T
8. 4
9. b 10. A’s: 4, B’s: 2
11. a, b 12. 454545
13. 7 14. c
15.
a b c d e f
S S C B S B
1
COMPSCI 230 Computer Systems Principles B
Questions:
1. Let N=16, M=64 and P=8, where N is the number of virtual addresses, M is the
number of physical addresses in main memory, and P is the page size in bytes.
Given the table below, what is the physical address, written in binary, that
corresponds to virtual address 0x5?
Valid bit PPN
3 Pts
2. Which of the following(s) about virtual memory address transition is not true?
a. Page tables may be used to map virtual memory addresses to physical
addresses in the RAM
b. Memory management unit (MMU) implements address translation for virtual
memory.
c. Page tables may be used to map virtual memory addresses to physical
addresses in the Disk.
d. When an entry in a page table has its valid bit set to "valid" (1), the "address"
field of that entry may refer to an address on Disk.
2 Pts
2
COMPSCI 230 Computer Systems Principles B
3. Here is a fragment of code shared between N threads:
1. #include <semaphore.h>
2. sem_t s;
3. sem_init(&s, 0, 1);
......
17.
18. printf(“Before I start, the bucket is %i.\n”, bucket_size);
19.
20. while (bucket_size > 0) {
21.
22. printf(“I am filling the bucket with 1 cup and the bucket is %i.\n”,
bucket_size);
23.
24. bucket_size--;
25.
26. sleep(10);
27.
28.
29. }
30.
......
This code is simulating filling a bucket of water 1 cup at a time. The more bucket
fillers we have the better. The problem is that we can only have 1 bucket filler fill the
bucket at a time without a fight (not much room in the bucket filling area!).
Indicates the line number(s) where sem_wait and sem_post should be inserted so
as to ensure correct output and also allow multiple bucket fillers to fill the bucket
without being delayed by other processes' sleep. Noticed that sem_wait and
sem_post cannot be inserted on the same line. No partial credit.
[Show Less]