How to write the logic to schedule tasks where I need to:
- Schedule
len(task_fifo)
tasks on a processor grouppg
, pg
has up top
processors1 <= num_of_processors <= p
processors.- To reserve
pg.reserve(num_of_slots, num_of_processors)
process group needs to know slot count, and number of processors to reserve - But the policy states
n <= num_of_slots <= m
may be reserve at a time. - 1 slot runs 1 task
How to do determine the slots and number of processors want to determine the queue length that I should reserve on I want to know how would you go about coding this logic, using mathematics to determine the outcome.
E.g. If I have task_fifo
of 457 tasks, which can be scheduled on up to 8 processors, but each processor takes minimum of 100 tasks and maximum of 1000 tasks, then, I would do pg.reserve(115, 4)
and add dummy tasks to even it out "NOOP".
Knowing this I can schedule it as
# min_slots = 100
# max_slots = 1000
# max_processors = 8
# Since 457 tasks cant be divided equally on 4 processors,
# 114 * 4 = 456 < 457 (is less)
# 115 * 4 = 460 > 457 (is more, but can add NOOPs)
reservation = pg.reserve(115, 4)
# So I add 3 'NOOP' tasks in to task fifo
task_fifo.append("NOOP")
task_fifo.append("NOOP")
task_fifo.append("NOOP")
reservation.run(task_fifo)
| task | 115 | 115 | 115 | 115 | 0 | 0 | 0 | 0 |
--------------------------------------------------------
| proc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
If task length was greater then max_slots*max_processors
then I will need to run tasks with multiple reservations. So to schedule where 8473
tasks:
reservation1 = pg.reserve(1000,8)
reservation2 = pg.reserve(119,4)
tasks_fifo + ["NOOP"]*3
reservation1.run(tasks_fifo)
reservation2.run(tasks_fifo)
reservation1:
| task | 1000 | 1000 | 1000 | 1000 | 1000 | 1000 | 1000 | 1000 |
----------------------------------------------------------------
| proc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
reservation2:
| task | 119 | 119 | 119 | 119 | 0 | 0 | 0 | 0 |
--------------------------------------------------------
| proc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
I want to determine number of reservation should I make and their number of slots and processors.
It be great help!