Name:
CS 3331 Exam 3 Fall 2024
SOLUTIONS
MAKE SURE THAT YOUR COPY OF THE SOLUTION SHEET HAS 17 PAGES. You may add additional pages to the back
as needed. Be sure to put your name and a page number on each sheet that you add. Indicate in the question that your answer
is on an extra page.
1. (a) [1 point] One thread in a process can never write to the stack of another thread within the same process.
⃝True
⃝False
(b) [1 point] A routine that is thread-safe is also reentrant.
⃝True
⃝False
(c) [1 point] Non-deterministic behavior is always the result of a race condition.
⃝True
⃝False
(d) [1 point] A system that is in an unsafe state will eventually deadlock.
⃝True
⃝False
(e) [1 point] If a system contains a deadlock, then its Resource Allocation Graph will contain a cycle.
⃝True
⃝False
2. (a) [2 points] Intuitively, what is theworkandstrandof a computation?
(b) [2 points] When a child process is created usingfork()what segments of process memory are shared with the parent?
(c) [2 points] Given a base and bounds register, how would an MMU determine if a memory request can be granted or not? What happens if
the request is invalid?
(d) [2 points] List the requirements for a deadlock.
(e) [2 points] What’s the difference between progress and bounded waiting?
Page 2 of 17
3. (a) [1 point]bwill be in thesegment.
(b) [1 point]xwill be in the
segment.
(c) [1 point]pwill be in thesegment.
(d) [1 point]qwill be in thesegment.
(e) [1 point]*pwill be in thesegment.
(f) [1 point]*qwill be in thesegment.
(g) [1 point]f()will be in thesegment.
Page 3 of 17
4. [6 points] Draw the process tree below. Please make sure to label your vertices.
Page 4 of 17
5. (a) [8 points] Use the grid below if you wish to produce an execution table. If not, simply write your proof over the grid.
(b) [7 points] Use the table below for your execution. There may be more space in the table than necessary.
TimeT
0
T
1
interest[0]interest[1]
0FALSEFALSE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Page 6 of 17
6. (a) [3 points] Use the table below for your execution. There may be more space in the table than necessary.
TimeT A
1
T A
2
T B
1
T B
2
mutexgoagob
0120
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Page 7 of 17
(b) [3 points] Use the table below for your execution. There may be more space in the table than necessary.
TimeT A
1
T A
2
T B
1
T B
2
mutexgoagob
0120
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Page 8 of 17
(c) [2 points]
Page 9 of 17
(d) [5 points]
Page 10 of 17
7. (a) [5 points] Use the table below for your execution. There may be more space than nessecary.
TimeT
1
T
2
T
3
done
00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Page 11 of 17
(b) [5 points] Implement you monitor in the space below.
(c) [3 points]
Page 12 of 17
8. (a) [5 points] Use the tables below to execute the safety algorithm.
AllocationMaxStill NeedsAvailable
ABCABCABCABC
P
0
201213
.
P
1
101102
P
2
000303
P
3
021122
ProcessNeed for Finishing ProcessWorkFinish
Page 13 of 17
(b) [5 points] Execute the Banker’s algorithm using the tables below.
AllocationMaxStill NeedsAvailable
ABCABCABCABC
P
0
213
.
P
1
102
P
2
303
P
3
122
ProcessNeed for Finishing ProcessWorkFinish
Page 14 of 17
9. [5 points] Use the table below for your execution. There may be more space than necessary.
TimeT A
1
T A
2
T Wcount
00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Page 15 of 17
10. [8 points] Use the grid below if you wish to produce an execution table. If not, simply write your explanation over the grid.
Page 16 of 17
11. [8 points]
Page 17 of 17