程序代写代做代考 kernel concurrency algorithm EECS 3221E Fall 2020 Sample Questions

EECS 3221E Fall 2020 Sample Questions
1. For each of the statements below, circle the “T” letter following the statement if the statement is true; circle the “F” letter following the statement if the statement is false.
(a) The store instruction moves the content of a register to main memory.
TF
(b) With symmetric multiprocessing, no master-slave relationship exists between processors. .TF
(c) The operating system kernel is normally pre-loaded into memory and ready to be executed immediately after the power is turned on. T F
(d) The many-to-one multithreading model provides more concurrency than the one-to- one multithreading model. T F
(e) In the Storage-Device Hierarchy in a computer system, the cost per bit of a storage device at a higher level should never be cheaper than the cost per bit of a storage device at a lower level. T F
(f) With indirect communication, a communication link is established automatically when processes send or receive messages. .TF
(g) With Direct Memory Access (DMA), the device controller can transfer any amount of data from buffer storage directly to main memory without using any interrupts. .TF
(h) In modern general purpose operating systems, an interrupt always causes the system to execute in kernel mode.
TF
(i) Application programs can modify the content of the timer in user mode. .TF

2. Answer the following questions.
2.1. Assume that BUFFER_SIZE = 9 in the Bounded Buffer – Shared Memory Solution that does not require the use of semaphores for the Producer-Consumer Problem. Assume the following sequence of executions:
(a) The Producer process performs six (6) executions of all the code in the body of the while loop for the Producer process;
(b) After (a), the Consumer process performs two (2) executions of all the code in the body of the while loop for the Consumer process;
(c) After (b), the Producer process attempts to execute as many times as possible all the code in the body of the while loop for the Producer process while the Consumer process does not execute any further.
You are required to fill in the answer for each of the following questions:
(1) In (c) above, the total number of times that the Producer process will be able to execute all the code in the body of the while loop for the Producer process is ____________________.
(2) After (c), the value for the integer variable “in” will be _______________. (3) After (c), the value for the integer variable “out” will be _______________.

2.2. Assume that BUFFER_SIZE = 9 in the Bounded Buffer – Shared Memory Solution that does not require the use of semaphores for the Producer-Consumer Problem. Assume the following sequence of executions:
(a) The Producer process performs six (6) executions of all the code in the body of the while loop for the Producer process;
(b) After (a), the Consumer process performs two (2) executions of all the code in the body of the while loop for the Consumer process;
(c) After (b), the Producer process attempts to execute as many times as possible all the code in the body of the while loop for the Producer process while the Consumer process does not execute any further.
(d) After (c), the Consumer process attempts to execute as many times as possible all the code in the body of the while loop for the Consumer process while the Producer process does not execute any further.
You are required to fill in the answer for each of the following questions:
(1) In (d) above, the total number of times that the Consumer process will be able to execute all the code in the body of the while loop for the Consumer process is __________________.
(2) After (d), the value for the integer variable “in” will be _______________. (3) After (d), the value for the integer variable “out” will be ______________.

3. Answer the following questions.
Calculate the (a) average waiting time; and (b) average turnaround time, respectively,
when the following scheduling algorithms are used to schedule the set of processes with corresponding burst times below. (You may assume that the context switch time is 0.)
(1) Round Robin (RR) Scheduling (you may assume that the time quantum is 2) (2) SJF Nonpreemptive Scheduling
(3) SJF Preemptive Scheduling
Process Arrival Time Burst Time P1 0.0 8
P2 2.0 4
P3 5.0 2
P4 7.0 4

4. Draw a diagram of process state. The diagram should include the different process states, and should also include the event(s)/circumstance(s) which cause a process to change from one state to another state.

5. Write the pseudo code for the Bounded Buffer – Shared Memory Solution that does not require the use of semaphores for the Producer-Consumer Problem.

EECS 3221E Fall 2020 Answers to Sample Questions
1. For each of the statements below, circle the “T” letter following the statement if the statement is true; circle the “F” letter following the statement if the statement is false.
(a) The store instruction moves the content of a register to main memory.
TF
(b) With symmetric multiprocessing, no master-slave relationship exists between processors. .TF
(c) The operating system kernel is normally pre-loaded into memory and ready to be executed immediately after the power is turned on. T F
(d) The many-to-one multithreading model provides more concurrency than the one-to- one multithreading model. T F
(e) In the Storage-Device Hierarchy in a computer system, the cost per bit of a storage device at a higher level should never be cheaper than the cost per bit of a storage device at a lower level. T F
(f) With indirect communication, a communication link is established automatically when processes send or receive messages. .TF
(g) With Direct Memory Access (DMA), the device controller can transfer any amount of data from buffer storage directly to main memory without using any interrupts. .TF
(h) In modern general purpose operating systems, an interrupt always causes the system to execute in kernel mode.
TF (i) Application programs can modify the content of the timer in user mode.
.TF 2. Answer the following questions.

2.1. Assume that BUFFER_SIZE = 9 in the Bounded Buffer – Shared Memory Solution that does not require the use of semaphores for the Producer-Consumer Problem. Assume the following sequence of executions:
(a) The Producer process performs six (6) executions of all the code in the body of the while loop for the Producer process;
(b) After (a), the Consumer process performs two (2) executions of all the code in the body of the while loop for the Consumer process;
(c) After (b), the Producer process attempts to execute as many times as possible all the code in the body of the while loop for the Producer process while the Consumer process does not execute any further.
You are required to fill in the answer for each of the following questions:
(1) In (c) above, the total number of times that the Producer process will be able to execute all the code in the body of the while loop for the Producer process is _________4___________.
(2) After (c), the value for the integer variable “in” will be _______1_________. (3) After (c), the value for the integer variable “out” will be ______2_________.

2.2. Assume that BUFFER_SIZE = 9 in the Bounded Buffer – Shared Memory Solution that does not require the use of semaphores for the Producer-Consumer Problem. Assume the following sequence of executions:
(a) The Producer process performs six (6) executions of all the code in the body of the while loop for the Producer process;
(b) After (a), the Consumer process performs two (2) executions of all the code in the body of the while loop for the Consumer process;
(c) After (b), the Producer process attempts to execute as many times as possible all the code in the body of the while loop for the Producer process while the Consumer process does not execute any further.
(d) After (c), the Consumer process attempts to execute as many times as possible all the code in the body of the while loop for the Consumer process while the Producer process does not execute any further.
You are required to fill in the answer for each of the following questions:
(1) In (d) above, the total number of times that the Consumer process will be able to execute all the code in the body of the while loop for the Consumer process is ________8__________.
(2) After (d), the value for the integer variable “in” will be _______1________. (3) After (d), the value for the integer variable “out” will be ______1________.

3. Answer the following questions.
Calculate the (a) average waiting time; and (b) average turnaround time, respectively,
when the following scheduling algorithms are used to schedule the set of processes with corresponding burst times below. (You may assume that the context switch time is 0.)
(4) Round Robin (RR) Scheduling (you may assume that the time quantum is 2) (5) SJF Nonpreemptive Scheduling
(6) SJF Preemptive Scheduling
Process Arrival Time Burst Time P1 0.0 8
P2 2.0 4
P3 5.0 2
P4 7.0 4
ANSWERS:
(1) RR:
(a) average waiting time: (8+2+3+7)/4 = 5
(b) average turnaround time (16+6+5+11)/4 = 9.5
(2) SJF Nonpreemptive Scheduling
(a) average waiting time: (0+8+3+7)/4 = 4.5
(b) average turnaround time (8+12+5+11)/4 = 9
(2) SJF Preemptive Scheduling
(a) average waiting time: (0+10+1+1)/4 = 3
(b) average turnaround time (18+4+3+5)/4 = 7.5

4. Draw a diagram of process state. The diagram should include the different process states, and should also include the event(s)/circumstance(s) which cause a process to change from one state to another state.
ANSWER:

5. Write the pseudo code for the Bounded Buffer – Shared Memory Solution that does not require the use of semaphores for the Producer-Consumer Problem.
ANSWER:
#define BUFFER_SIZE 10 typedef struct {
… } item;
item buffer[BUFFER_SIZE]; int in = 0;
int out = 0;
Producer Process pseudo code:
item next_produced; while (true) {
/* produce an item in next produced */ while (((in + 1) % BUFFER_SIZE) == out)
; /* do nothing */ buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE; }
Consumer Process pseudo code:
item next_consumed; while (true) {
while (in == out)
; /* do nothing */
next_consumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
/* consume the item in next consumed */ }