Proportional = Fair share
Instead of optimizing turnaround and response time, scheduler guarantee fair amount of CPU share.
Lottery Scheduling - Randomness
Each lottery tickets gives the different share per job.
It does not guarantee the perfect share that the ticket represents, but as the job takes more time, it approximates.
- Randomness:
- Oftern avoids strange corner-case behaviours that a more traditional algorithm may have trouble handling.
- Lightweight: It does not have to tract how much CPU the job used; but track how many tickets left.
- Very fast: Since the decision is simply made by the ticket.
Method
- Ticket Currency: User can freely slice up the given tickets into its own currency. If user A has 100 tickets, it can gives 300 tickets to its programs…
- Ticket Transfer: Process can temporarily transfer the tickets to the another process. It is beneficial to client/server situation.
- Ticket Inflation: It is non-sense in the race condition, but between trusted processes, asks system it needs more tickets.
Implementation
It is very easy to implement - needs randommizer, data structures, total number of tickets.
1 | int counter = 0; |
Stride Scheduling - deterministic
As can be seen, randomness can simplify the scheduler but it does not guarantee the exact proportions especially over short time scales.
- Stride Scheduling: a deterministic fair-share scheduler
- Each job has a stride; inverse in proportion to the number of tickets it has.
- Each time process runs, increment counter (called pass value) by its stride; track the total CPU usage.
- Scheduler decides which process to run based on stride and pass values.
- run the process has the lowest pass values, and increase by its stride.
Then why do we use the lottery scheduling then?
- run the process has the lowest pass values, and increase by its stride.
- Imagine if there is a new job assigned.
- What the pass value should be?
- Lotter scheduling does not have to care about process state (CPU usage, pass values). Only consider tickets.
- Therefore, it is easier to add a new process in the list.
Summary
For these reasons, Proportional and stride scheduling are not widely used:
- These approaches do not get along well with IO.
- Hard to implement tickets allocation; how many to which?
In case of virtualization environment, say I would like to use 25% of system to run the virtual machine, proprotional scheduling might be useful.