Operating Systems

================ Start Lecture #5 ================

Remark: A very small change was made to lab2 (on the mailing list thurs evening). The name of the random number file must be random-numbers. The first sentence of the last paragraph on page 1 now states.

The function randomOS(U) reads a random non-negative integer X from a file named random-numbers (in the current directory) and returns the value 1+(X mod U).

Variants of Round Robin

Priority Scheduling

Each job is assigned a priority (externally, perhaps by charging more for higher priority) and the highest priority ready job is run.

Priority aging

As a job is waiting, raise its priority so eventually it will have the maximum priority.

Selfish RR (SRR, **, SRR, **)

Shortest Job First (SPN, SJF, SJF, SJF)

Sort jobs by total execution time needed and run the shortest first.

Homework: 39, 40. Note that when the book says RR with each process getting its fair share, it means Processor Sharing.

Preemptive Shortest Job First (PSPN, SRT, PSJF/SRTF, --)

Preemptive version of above

Highest Penalty Ratio Next (HPRN, HRN, **, **)

Run the process that has been “hurt” the most.

Remark: Recall that SFJ/PSFJ do a good job of minimizing the average waiting time. The problem with them is the difficulty in finding the job whose next CPU burst is minimal. We now learn two scheduling algorithms that attempt to do this (approximately). The first one does this statically, presumably with some manual help; the second is dynamic and fully automatic.

Multilevel Queues (**, **, MLQ, **)

Put different classes of processs in different queues

Multilevel Feedback Queues (FB, MFQ, MLFBQ, MQ)

As with multilevel queues above we have many queues, but now processs move from queue to queue in an attempt to dynamically separate “batch-like” from interactive processs so that we can favor the latter.

Theoretical Issues

Considerable theory has been developed.

Medium-Term Scheduling

In addition to the short-term scheduling we have discussed, we add medium-term scheduling in which decisions are made at a coarser time scale.

Long Term Scheduling

2.5.4: Scheduling in Real Time Systems

Skipped

2.5.5: Policy versus Mechanism

Skipped.

2.5.6: Thread Scheduling

Skipped.

Research on Processes and Threads

Skipped.

Chapter 3: Deadlocks

A deadlock occurs when every member of a set of processes is waiting for an event that can only be caused by a member of the set.

Often the event waited for is the release of a resource.

In the automotive world deadlocks are called gridlocks.

Old Reward: I used to give one point extra credit on the final exam for anyone who brings a real (e.g., newspaper) picture of an automotive deadlock. Note that it must really be a gridlock, i.e., motion is not possible without breaking the traffic rules. A huge traffic jam is not sufficient. This was solved last semester so no reward any more. One of the winners in on my office door.

For a computer science example consider two processes A and B that each want to print a file currently on tape.

  1. A has obtained ownership of the printer and will release it after printing one file.
  2. B has obtained ownership of the tape drive and will release it after reading one file.
  3. A tries to get ownership of the tape drive, but is told to wait for B to release it.
  4. B tries to get ownership of the printer, but is told to wait for A to release the printer.

Bingo: deadlock!

3.1: Resources

The resource is the object granted to a process.

3.1.1: Preemptable and Nonpreemptable Resources