- In the context of variable partition memory management schemes:
a) Briefly explain the First-Fit algorithm.
b) Briefly explain the Best-Fit algorithm.
Given a variable partition memory management scheme with the following free list:
Free element |
Size in KB |
1 |
100 |
2 |
500 |
3 |
200 |
4 |
300 |
5 |
600 |
This free list may be represented as (100, 500, 200, 300, 600); use this notation in your table below.
The following memory requests will be received in order: 212, 417, 112, 426 (size in KB).
c) Show how memory is allocated using the First-Fit algorithm by filling in this table:
Request # |
Size in KB |
Request Satisfied (Y/N)? |
Updated Free List |
1 |
212 |
Y/N |
( ) |
2 |
417 |
Y/N |
( ) |
3 |
112 |
Y/N |
( ) |
4 |
426 |
Y/N |
( ) |
d) Repeat for the Best-Fit algorithm beginning, again, with the original free list.
- Consider this solution for a Producer-Consumer sharing a bounded buffer of size N.
Producer: Consumer:
while (true) { while (true) {
wait(A); wait(B);
wait(C); wait(C);
/* put into the buffer */ /* take out of the buffer */
signal(C); signal(C);
signal(B); signal(A);
} }
The problem is to consider the effects of the initialization of the semaphores A, B, C with respect to i) a correct solution and whether the solution guarantees ii) mutual exclusion, iii) no deadlock, and iv) no starvation. The table below has five different initializations and for each initialization answer Yes/No to the previous four questions. Draw this table on your solution paper. Note: The definition of starvation here is that it is possible for only one of the two processes to make progress.
Warning: do NOT guess, just leave blank (+1 point for correct answers, 0 point for blanks, -1 point for incorrect answers).
|
A=N,B=0,C=0 |
A=0,B=N,C=1 |
A=N,B=0,C=1 |
A=0,B=0,C=1 |
A=N,B=0,C=2 |
Correct Solution: |
Y/N |
Y/N |
Y/N |
Y/N |
Y/N |
Guarantees Mutual Exclusion: |
Y/N |
Y/N |
Y/N |
Y/N |
Y/N |
Guarantees No Deadlock: |
Y/N |
Y/N |
Y/N |
Y/N |
Y/N |
Guarantees No Starvation: |
Y/N |
Y/N |
Y/N |
Y/N |
Y/N |
- Rewrite F(a,b,c,d) = S (0,3,4,6,7,8,10,12,14) in simplified product-of-sums form.
- Design the needed hardware that would allow for the execution of Arithmetic and Logical Instructions of a generic microprocessor. The processor has a register file that consists of eight 8-bit registers and an 8-bit ALU. It uses a two-operand addressing format where a register can be the source of one operand and also the destination register. For example, the following are typical instructions:
ADD R1, R2 |
|
T1 <- R1 + R2 |
SUB R1, R1 |
|
R1 <- R1 - R1 |
AND R3,R4 |
|
R3 <- R3 and R4 |
The instruction format for "op rd, rs" is as follows: opcode(4 bits) rd(3 bits) rs(3 bits) plus other fields that are not needed for this problem.
Draw a diagram showing how such a scheme can be implemented. Clearly label the components and connections in your design and write a brief explanation of your approach. You may use block diagrams for standard components you may need, such as encoders, decoders, multiplexers, shifters, counters, etc. The following is the beginning of the diagram.