Question

In: Other

1- Which of the following scheduling algorithms could result in starvation? Why? If any, show how...



1- Which of the following scheduling algorithms could result in starvation? Why? If any, show how can starvation problem be resolved.

a. First-come, first-served (FCFS)
b. Shortest job first (SJF)
c. Round robin (RR)
d. Priority?


2- Illustrate Peterson solution to critical section problem, showing how it satisfy the conditions of mutual exclusion, progress, and bounded waiting!

3- What is the meaning of the term busy waiting? What other kinds of waiting are there in an operating system? Can busy waiting be avoided altogether? Explain your answer.

4- Explain why interrupts are not appropriate for implementing synchronization primitives in multiprocessor systems.


5- Which of the following components of program state are shared across threads in a multithreaded process?
a. Register values
b. Heap memory
c. Global variables
d. Stack memory

6- Using pseudo C like code, illustrate two algorithms uses hardware synchronization.

7- Semaphores are used to overcome a drawback of hardware synchronization, what is this drawback, and how semaphores addresses this drawback?

Solutions

Expert Solution

1.

The following algorithms results to starvation:

Shortest Job First.

Priority

Explanation:

For Shortest Job First

  • The occurrence of starvation in shortest job first is possible when the process of higher burst time will execute before the lower burst time process.
  • The lower burst time process is there in the queue.
  • Thus, in this case the higher burst time process feels the starvation.

The solution for the starvation is to avoid the scheduling of jobs when the job pool is full.

The pool must wait to be empty for the execution of further processes.

For Priority

  • The processes with higher priority will execute first.
  • Thus, the lower burst time process feels the starvation.

The solution of the starvation for priority is that the processes which are waiting for their execution from a long time, their priorities will be increased.

2.

The illustrated Peterson solution to the critical section problem is as follows:

Code for process a:

do {

flag[a] := TRUE;

turn := b;

while (flag [b] and turn = b) do no-op;

CS

flag [a] := FALSE;

RS }

while(1);

Code for process b:

do {

flag[b] := TRUE;

turn := a;

while (flag [a] and turn = i) do no-op;

CS

flag [b] := FALSE;

RS }

while(1);

where, CS = Critical section and `

RS = Remainder section

From the above illustrated Peterson solution, the following conditions are satisfied.

Mutual exclusion: From the above illustrated solution, at a time only one process will enter in the critical section.

Bounded waiting: After the execution of the process a it will set the flag as false.

Then only the process b will enter in the critical section.

Thus, the process is bounded.

Hence, the above illustration follows the property of bounded waiting.

Progress: If some another process wants to execute in its critical section, when no process is executing its critical section then the processes which are not in their remainder section will decide which process will enter in the critical section.

After the execution of the process in the critical section, they will set their flag as false.

After that some other process will execute.

Thus, the progress property is also satisfied.

3.

  • The term busy waiting refers to the process waiting for the condition to be true.
  • If a program is reached to an appropriate state, then there is a need of waking up the process which is slept before, to sustain the accompanying overhead.
  • With this, the busy waiting can be avoided.

4.

  • The processes will not execute in the processor where the interrupt is disable.
  • But they can run on any different processor where the interrupt is not disabled,
  • This is the limitation of interrupt.
  • Thus, the interrupts are not appropriate.

5.

The components shared across are as follows:

Heap memory

Global memory

Explanation:

The heap memory belongs to the whole process and not to any single thread.

All threads of the process work on this memory, that’s why the memory is shared.

6.

The code for test-and-set with mutual exclusion is as follows:

boolean lock = false;

do {

while (TestAndSet(lock));

CS

lock = false;

RS

} while (TRUE);

The code for swap with mutual exclusion is as follows:

boolean lock;

do {

key = true;        

while (key == true)

Swap(lock,key);

CS

lock = false;

RS

} while (TRUE);

where, CS = Critical section and

RS = Remainder section

7.

With the help of semaphores, the critical section can be accessed by more than one thread.

Since, they are more flexible to manage the resources.

Thus, they are more useful to use.


Related Solutions

Which of the following is true? Select one: a. No deadlock implies no starvation; b. Starvation...
Which of the following is true? Select one: a. No deadlock implies no starvation; b. Starvation implies deadlock. c. No starvation implies no deadlock; d. Deadlock doesn’t imply starvation; Which of the following indicates that Pi can enter the critical section in Peterson’s solution? Select one: a. flag[j] == true or turn == i b. flag[j] == true and turn == j c. flag[j] == false or turn == j d. flag[j] == false or turn == i Assume the...
(Python or C++) We are going to implement the following scheduling algorithms that we discussed in...
(Python or C++) We are going to implement the following scheduling algorithms that we discussed in class: 1. First-Come First-Served (FCFS) 2. Shortest Remaining Time First (SRTF) 3. Highest Response Ratio Next (HRRN) 4. Round Robin, with different quantum values (RR) We are interested to compute the following metrics, for each experiment: _ The average turnaround time _ The total throughput (number of processes done per unit time) _ The CPU utilization _ The average number of processes in the...
Answer: 1. List the short term (CPU) scheduling algorithms implemented in the OS.
Answer: 1. List the short term (CPU) scheduling algorithms implemented in the OS.
in C++ We are going to implement the following scheduling algorithms 1. First-Come First-Served (FCFS) 2....
in C++ We are going to implement the following scheduling algorithms 1. First-Come First-Served (FCFS) 2. Shortest Remaining Time First (SRTF) 3. Highest Response Ratio Next (HRRN) 4. Round Robin, with di_erent quantum values (RR) We are interested to compute the following metrics, for each experiment: _ The average turnaround time _ The total throughput (number of processes done per unit time) _ The CPU utilization _ The average number of processes in the ready queue The simulator needs to...
Draw six Gantt charts that illustrate the execution of these processes using the following scheduling algorithms:
Draw six Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: 
Nondisjunction of chromosome #21 in which of the following (1-7) could result in a fetus/child with...
Nondisjunction of chromosome #21 in which of the following (1-7) could result in a fetus/child with trisomy 21 (47,XX+21) or (47,XY+21)? To indicate your choices, type an “R” at the end of each RIGHT choice, and a “W” at the end of each WRONG choice. I. Anaphase 1 in spermatogenesis II. Anaphase 2 in spermatogenesis III. Anaphase 1 in oogenesis IV. Anaphase 2 in oogenesis V. The first anaphase of a normal zygote. VI. The anaphase in one of the...
1)Which of the following will be expected to be activated during times of prolonged starvation? (select...
1)Which of the following will be expected to be activated during times of prolonged starvation? (select all correct answers) Gluconeogenesis in kidney Lipogenesis in liver Ketogenesis in liver Lipolysis in adipose Glycogenesis in muscle Ketone utilization in brain 2)Which of the following is a description of re-purposing drugs for treatment of inborn errors of metabolism? (select one) Use of an antisense oligonucleotide such as mipomersen that inhibits production of a toxic protein Using proteostatis regulators to increase the production of...
IN JAVA Implement SRT scheduling algorithms based on following actions: The simulation maintains the current time,...
IN JAVA Implement SRT scheduling algorithms based on following actions: The simulation maintains the current time, t, which is initialized to 0 and is incremented after each simulation step. Each simulation step then consists of the following actions: repeat until Rᵢ == 0 for all n processes /* repeat until all processes have terminated */ while no process is active, increment t /* if no process is ready to run, just advance t */ choose active processes pᵢ to run...
IN JAVA Implement SJF scheduling algorithms based on following actions: The simulation maintains the current time,...
IN JAVA Implement SJF scheduling algorithms based on following actions: The simulation maintains the current time, t, which is initialized to 0 and is incremented after each simulation step. Each simulation step then consists of the following actions: repeat until Rᵢ == 0 for all n processes /* repeat until all processes have terminated */ while no process is active, increment t /* if no process is ready to run, just advance t */ choose active processes pᵢ to run...
IN jAVA Language PLEASE Write a JAVA program that implements the following disk-scheduling algorithms: a. FCFS...
IN jAVA Language PLEASE Write a JAVA program that implements the following disk-scheduling algorithms: a. FCFS b. SSTF c. SCAN Your program will service a disk with 5,000 cylinders numbered 0 to 4,999. The program will generate a random series of 50 requests and service them according to each of the algorithms you chose. The program will be passed the initial position of the disk head as a parameter on the command line and report the total amount of head...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT