13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

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.

Exercises 557. Here are some procedures that give you exponentially distributed random numbers:function Random(var Seed : integer) : real;{ Linear-congruential random number generator, for32-bit computers. Start the Seed anywhere you like,but then don’t touch it. Returns a pseudo-randomnumber between 0 and 1. }constMultiplier = 1103515245;Adder = 12345;Modulus = 2147483648; { 2 ** 31 }beginSeed := (Seed * Multiplier + Adder) mod Modulus;Random := Seed / Modulus;end Random;function Expo(Lambda: real; var Seed : integer) : real;{ Returns a random number distributed according tothe exponential distribution with parameter Lambda.Seed should be set once and then not touched. }beginExpo:= -ln(Random(Seed)) / Lambda;end Expo;Write a program to generate 1000 samples from Expo(3) and draw a histogram (abar graph) showing how many samples fall in each interval of length 0.1 from 1 to10. For example, how many samples were in the half-open interval (2.3, 2.4]?8. Write a program that generates n processes, with arrival intervals drawn from anexponential distribution with parameter α and service requirements drawn from anexponential distribution with parameter β. The program then schedules theseprocesses according to either FCFS or SPN and computes T , M , P , and R for eachprocess. Run your program with n = 100 and ρ=0.5, 0.9, 1.5.9. Using a similar program, show the length of the ready list for FCFS and how itchanges over time when ρ = 0.5, 0.9, and 1.5. Can you predict the average lengthjust knowing ρ?10. Devise a data structure that allows SRR to be implemented efficiently. In particular,how do we organize the new list, and how do we store the current priorities?11. Predict the behavior of the LCFS (last come, first served) non-preemptive policy.Simulate this policy with a program, and compare the results to your prediction.12. Repeat the previous exercise with a preemptive LCFS policy.13. Consider a preemptive HPRN policy. Can it be implemented exactly? If not, howwould you approximate it?14. What countermeasures can an inherently short process take to get better service ifthe scheduling method favors long processes?15. Which of the methods discussed in this chapter have a scheduling cost that isindependent of the number of processes in the ready list?16. Some operating systems are used in environments where processes must getguaranteed service. Deadline scheduling means that each process specifies howmuch service time it needs and by what real time it must be finished. Design apreemptive algorithm that services such processes. There will be occasions whendeadlines cannot be met; try to discover these situations as early as possible (before

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

Saved successfully!

Ooh no, something went wrong!