Hi, I'm just trying to wrap my head around the implementation of a very basic lottery scheduling.
I understand that each process can be assigned some number of tickets, but I don't understand how a winning ticket gets mapped to a certain process.
E.g.
Proc. A has 5 tickets
Proc. B has 1 ticket
So A has probability 5/6 to win, and B has 1/6 to win.
So in the scheduler, I'll choose: rand() % ((6 +1) - 1)) + 1, to give me the winning ticket in the range [1,6]. Just say the winning ticket = 4. How do I determine which process has this ticket #?
When I assigned A 5 tickets, how do I tell A which tickets he has? How do real implementations make this decision?
Thanks a lot!
I understand that each process can be assigned some number of tickets, but I don't understand how a winning ticket gets mapped to a certain process.
E.g.
Proc. A has 5 tickets
Proc. B has 1 ticket
So A has probability 5/6 to win, and B has 1/6 to win.
So in the scheduler, I'll choose: rand() % ((6 +1) - 1)) + 1, to give me the winning ticket in the range [1,6]. Just say the winning ticket = 4. How do I determine which process has this ticket #?
When I assigned A 5 tickets, how do I tell A which tickets he has? How do real implementations make this decision?
Thanks a lot!