05.08.2014 Views

Operating Systems 2: Tutorial 2 Questions:

Operating Systems 2: Tutorial 2 Questions:

Operating Systems 2: Tutorial 2 Questions:

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Tutorial</strong> 2 <strong>Operating</strong> <strong>Systems</strong> 2<br />

Faculty of Engineering Science and the Built Environment<br />

Department of Electrical, Computer and Communications Engineering<br />

<strong>Questions</strong>:<br />

<strong>Operating</strong> <strong>Systems</strong> 2: <strong>Tutorial</strong> 2<br />

1. Give several definitions of process. Why, do you suppose, is there no universally accepted<br />

definition?<br />

2. Sometimes the terms user and process are used interchangeably. Define each of these terms.<br />

In what circumstances do they have similar meaning?<br />

3. Describe the differences among short-term, medium-term, and long-term scheduling.<br />

4. Describe the actions a kernel takes to context switch between processes.<br />

5. What are two differences between user-level threads and kernel-level threads? Under what<br />

circumstances is one type better than the other?<br />

6. Describe the actions taken by a kernel to context switch between kernel-level threads.<br />

7. Describe the actions taken by a thread library to context switch between user-level threads.<br />

8. What resources are used when a thread is created? How do they differ from those used when<br />

a process is created?<br />

9. Define the difference between preemptive and nonpreemptive scheduling. State why strict<br />

nonpreemptive scheduling is unlikely to be used in a computer center.<br />

10. Consider a variant of the Round-Robin (RR) scheduling algorithm where the entries in the<br />

ready queue are pointers to the PCBs.<br />

a. What would be the effect of putting two pointers to the same process in the ready<br />

queue?<br />

b. What would be the major advantages and disadvantages of this scheme?<br />

c. How would you modify the basic RR algorithm to achieve the same effect without the<br />

duplicate pointers?<br />

11. What advantage is there in having different time-quantum sizes on different levels of a<br />

multilevel queueing system?<br />

12. Consider the following preemptive priority-scheduling algorithm based on dynamically<br />

changing priorities. Larger priority numbers imply higher priority. When a process is waiting<br />

for the CPU (in the ready queue but not running), its priority changes at a rate α; when it is<br />

running, its priority changes at a rate β. All processes are given a priority of 0 when they<br />

enter the ready queue. The parameters α and β can be set to give many different scheduling<br />

algorithms.<br />

a. What is the algorithm that results from β > α >0?<br />

b. What is the algorithm that results from α < β


<strong>Tutorial</strong> 2 <strong>Operating</strong> <strong>Systems</strong> 2<br />

13. Many CPU scheduling algorithms are parameterized. For example, the RR algorithm requires<br />

a parameter to indicate the time slice. Multilevel feedback queues require parameters to<br />

define the number of queues, the scheduling algorithms for each queue, the criteria used to<br />

move processes between queues, and so on. These algorithms are thus really sets of<br />

algorithms (for example, the set of RR algorithms for all time slices, and so on). One set of<br />

algorithms may include another (for example, the FCFS algorithm is the RR algorithm with<br />

an infinite time quantum). What (if any) relation holds between the following pairs of sets of<br />

algorithms?<br />

a. Priority and SJF<br />

b. Multilevel feedback queues and FCFS<br />

c. Priority and FCFS<br />

d. RR and SJF<br />

14. Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those<br />

processes that have used the least processor time in the recent past. Why will this algorithm<br />

favour I/O-bound programs and yet not permanently starve CPU-bound programs?<br />

15. Explain the differences in the degree to which the following scheduling algorithms<br />

discriminate in favor of short processes:<br />

a. FCFS<br />

b. RR<br />

c. Multilevel feedback queues<br />

16. Give several reasons why the study of concurrency is appropriate and important for students<br />

of operating systems.<br />

17. Explain why the following statement is false: When several threats access shared information<br />

in main memory, mutual exclusion must be enforced to prevent the production of<br />

indeterminate results.<br />

18. What is the real significance of Dekker’s algorithm?<br />

19. Mutual exclusion primitives can be implemented with busy waiting or with blocking. Discuss<br />

the applicability and relative merits of each approach.<br />

20. Explain in detail how binary semaphores and binary semaphore operations can be<br />

implemented in the kernel of an operating system.<br />

21. Define deadlock and give an example of a deadlock involving only a single process and a<br />

single resource.<br />

22. Give an example of a simple resource deadlock involving three processes and three resources.<br />

Draw the appropriate resource-allocation graph.<br />

23. Is it possible to have a deadlock involving only one single process? Explain your answer.<br />

24. State the four necessary conditions for a deadlock to exist. Give a brief intuitive argument for<br />

the necessity of each individual condition.<br />

25. Consider a system consisting of four resources of the same type that are shared by three<br />

processes, each of which needs at most two resources. Show that the system is deadlock free.<br />

26. Explain the intuitive appeal of deadlock avoidance over deadlock prevention.<br />

Lecturer: S. Dimitriou Page 2 of 3


<strong>Tutorial</strong> 2 <strong>Operating</strong> <strong>Systems</strong> 2<br />

27. We can obtain the banker’s algorithm for a single resource type from the general banker’s<br />

algorithm simply by reducing the dimensionality of the various arrays by 1. Show through an<br />

example that the multiple-resource-type banker’s scheme cannot be implemented by<br />

individual application of the single-resource-type scheme to each resource type.<br />

28. Can a system detect that some of its processes are starving? If you answer “yes,” explain how<br />

it can. If you answer “no,” explain how the system can deal with the starvation problem.<br />

29. Consider the following snapshot of a system:<br />

Allocation Max Available<br />

A B C D A B C D A B C D<br />

P o 0 0 1 2 0 0 1 2 1 5 2 0<br />

P 1 1 0 0 0 1 7 5 0<br />

P 2 1 3 5 4 2 3 5 6<br />

P 3 0 6 3 2 0 6 5 2<br />

P 4 0 0 1 4 0 6 5 6<br />

Answer the following questions using the banker’s algorithm:<br />

a. What is the content of the matrix Need?<br />

a. Is the system in a safe state?<br />

b. If a request from process P1 arrives for (0,4,2,0), can the request be granted<br />

immediately?<br />

30. Consider the following resource-allocation policy. Requests and releases for resources are<br />

allowed at any time. If a request for resources cannot be satisfied because the resources are<br />

not available, then we check any processes that are blocked, waiting for resources. If they<br />

have the desired resources, then these resources are taken away from them and are given to<br />

the requesting process. The vector of resources for which the waiting process is waiting is<br />

increased to include the resources that were taken away. For example, consider a system with<br />

three resource types and the vector Available initialized to (4,2,2). If process P0 asks for<br />

(2,2,1), it gets them. If P1 asks for (1,0,1), it gets them. Then, if P0 asks for (0,0,1), it is<br />

blocked (resource not available). If P2 now asks for (2,0,0), it gets the available one (1,0,0)<br />

and one that was allocated to P0 (since P0 is blocked). P0’s Allocation vector goes down to<br />

(1,2,1), and its Need vector goes up to (1,0,1).<br />

a. Can deadlock occur? If so, give an example. If not, which necessary condition cannot<br />

occur?<br />

b. Can indefinite blocking occur?<br />

31. In a system in which it is possible for a deadlock to occur, under what circumstances would<br />

you use a deadlock detection algorithm?<br />

32. Why is deadlock recovery such a difficult problem and why is it difficult to choose which<br />

processes to “flush” in deadlock recovery?<br />

Lecturer: S. Dimitriou Page 3 of 3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!