Skip to main content

Lottery Scheduling

 Giving tickets to the each processors. Regarding the tickets the Schedular pick the process. Here it will gives non-zero probability of being selected by the schedular operation.

Ways to Manipulate tickets


Ticket Currency

Currency allows a user with a set of tickets to allocate tickets among own jobs in whatever currency they would like the system then automatically converts said currency into the correct global value.

Transfer Tickets

A process can pass it tickets to another process.

Ticket inflation

A process can temporarily raise or lower the number of tickets it own.

Code

// counter: used to track if we’ve found the winner yet
2 int counter = 0;
3
4 // winner: use some call to a random number generator to
5 // get a value, between 0 and the total # of tickets
6 int winner = getrandom(0, totaltickets);
7
8 // current: use this to walk through the list of jobs
9 node_t *current = head;
10
11 // loop until the sum of ticket values is > the winner
12 while (current) {
13 counter = counter + current->tickets;
14 if (counter > winner)
15 break; // found the winner
16 current = current->next;
17 }
18 // ’current’ is the winner: schedule it...

Popular posts from this blog

Operating System

What is an operating system? An operating system (OS) is the program that, after being initially loaded into the computer by a boot program, manages all of the other application programs in a computer. The application programs make use of the operating system by making requests for services through a defined application program interface ( API ). In addition, users can interact directly with the operating system through a user interface, such as a command-line interface (CLI) or a graphical UI (GUI). Why use an operating system? An operating system brings powerful benefits to computer software and software development. Without an operating system, every application would need to include its own UI, as well as the comprehensive code needed to handle all low-level functionality of the underlying computer, such as disk storage, network interfaces and so on. Considering the vast array of underlying hardware available, this would vastly bloat the size of every application and make software