Open In App

Lottery Process Scheduling in Operating System

Last Updated : 26 Apr, 2023
Like Article

Prerequisite – CPU Scheduling, Process Management 

Lottery Scheduling is a type of process scheduling, somewhat different from other Scheduling. Processes are scheduled in a random manner. Lottery scheduling can be preemptive or non-preemptive. It also solves the problem of starvation. Giving each process at least one lottery ticket guarantees that it has a non-zero probability of being selected at each scheduling operation. In this scheduling every process has some tickets and the scheduler picks a random ticket and process having that ticket is the winner and it is executed for a time slice and then another ticket is picked by the scheduler. These tickets represent the share of processes. A process having a higher number of tickets give it more chance to get chosen for execution. 

Example – If we have two processes A and B having 60 and 40 tickets respectively out of total of 100 tickets. CPU share of A is 60% and that of B is 40%. These shares are calculated probabilistically and not deterministically. 


  1. We have two processes A and B. A has 60 tickets (ticket number 1 to 60) and B has 40 tickets (ticket no. 61 to 100).
  2. Scheduler picks a random number from 1 to 100. If the picked no. is from 1 to 60 then A is executed otherwise B is executed.
  3. An example of 10 tickets picked by the Scheduler may look like this follows:
Ticket number -  73 82 23 45 32 87 49 39 12 09.
Resulting Schedule -  B  B  A  A  A  B  A  A  A  A.
  1. A is executed 7 times and B is executed 3 times. As you can see that A takes 70% of the CPU and B takes 30% which is not the same as what we need as we need A to have 60% of the CPU and B should have 40% of the CPU. This happens because shares are calculated probabilistically but in a long run(i.e when no. of tickets picked is more than 100 or 1000) we can achieve a share percentage of approx. 60 and 40 for A and B respectively.

Ways to manipulate tickets –

  • Ticket Currency – Scheduler gives a certain number of tickets to different users in a currency and users can give it to their processes in a different currency. E.g. Two users A and B are given 100 and 200 tickets respectively. User A is running two processes and gives 50 tickets to each in A’s own currency. B is running 1 process and gives it all 200 tickets in B’s currency. Now at the time of scheduling tickets of each process are converted into global currency i.e A’s process will have 50 tickets each and B’s process will have 200 tickets and scheduling is done on this basis.
  • Transfer Tickets – A process can pass its tickets to another process.
  • Ticket inflation – With this technique a process can temporarily raise or lower the number of tickets it owns.

Advantages of Lottery Process Scheduling:

  1. Fairness: Lottery process scheduling is designed to be fair because every process has a chance of being selected. This ensures that no process is starved of CPU time, and it also helps to prevent monopolization of the CPU by a single process.
  2. Flexibility: The lottery process scheduling algorithm is highly flexible and can be easily adapted to handle various scheduling requirements, such as real-time scheduling, multi-processor scheduling, and so on.
  3. Simple implementation: The implementation of the lottery process scheduling algorithm is relatively simple compared to other scheduling algorithms, making it easier to develop and maintain.
  4. Combining with other scheduling algorithms: Lottery scheduling can be combined with other scheduling algorithms such as round-robin or priority scheduling to achieve specific scheduling goals.

Disadvantages of Lottery Process Scheduling:

  1. Overhead: The lottery process scheduling algorithm requires additional overhead because it must generate lottery tickets for each process and randomly select a winner. This overhead can be significant in systems with many processes.
  2. Complexity: Although the implementation of the lottery process scheduling algorithm is relatively simple, the algorithm itself can be quite complex, especially when compared to other scheduling algorithms such as round-robin or FIFO.
  3. Security: Lottery process scheduling is not a secure algorithm because it is based on randomness, which can be manipulated. An attacker could potentially gain an unfair advantage by manipulating the generation of lottery tickets, leading to security vulnerabilities.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads