nswer the following:
1 1. what are the advantages of a Virtual Machine architecture?
2. Depending on whether the information should be stored in a Process Control Block (PCB) or a Thread Control Block (TCB), enter PCB or TCB for each of the following five resources:
Stack
Memory allocation
Open files
Program Counter (Instruction Counter)
Registers
3. Given the following description of the life of a process, indicate its state at each point in time and indicate (yes or no) whether the event requires a context switch. Assume that:
• multiple processes are in the system,
• another process is running when this process arrives
• other processes are ready to run when this process blocks
• another process is ready to run when this process completes.
For EACH of these 9 events, tell its STATE, and answer YES/NO whether a context switch is involved for each:
Process is being created
Process is put into the ready queue
Process is given the CPU
Process executes a read from the disk
Disk read completes
Process is given the CPU
Process A is preempted by higher-priority process B
Process is given the CPU
Process completes
4. Describe the condition that results from the code below, where A and B are semaphores.
Process 1:
Acquire (A) (successful)
Request(B)
--------------------------------
Process 2:
Acquire( B ) (successful)
Request(A )
5. Consider this pseudocode below with a bounded buffer of size of 2.
empty and full are semaphores.
Producer:
while( true )
{ …
acquire( empty )
// insert item in buffer
release( full ) …
}
----------------------------
Consumer:
while( true )
{ …
acquire( full )
// remove item from buffer
release( empty )
}
What initial value should be given to each of these semaphores?
empty _______
full _______
6. For each of the following six instructions, indicate whether the instruction should be restricted to kernel mode or available in user mode. Explain your selection for each instruction.
a. Read shared memory ________
b. Read from disk ________
c. Read the clock ________
d. Change to kernel mode ________
e. Turn off interrupts ________
f. Change to user mode ________
7. list the three requirements, and explain how each is satisfied by this algorithm. The algorithm assumes two processes, 0 and 1.
boolean flag0 = false; // flag for process 0
boolean flag1 = false; // flag for process 1
int turn = 0;
Code for Process 0
while ( true )
{
flag0 = true; // indicate interest in critical section
turn = 1; // set turn to other process
while ( flag1 == true && turn == 1 ); // wait if process 1
// wants critical section
// and it is
// process 1’s turn
// execute critical section
flag0 = false; // indicate no interest in critical section
}
8. In the bounded buffer solution shown in Figures 5.9 and 5.10 (pp. 219-220), if the order of the first two wait instructions in the consumer process were reversed. In other words, the consumer process would begin:
do {
wait ( mutex );
wait ( full );
…
Would the solution still be correct? Explain why or why not.
9. Compare context switching between processes to context switching between threads.