1

How to write the logic to schedule tasks where I need to:

  1. Schedule len(task_fifo) tasks on a processor group pg,
  2. pg has up to p processors 1 <= num_of_processors <= p processors.
  3. To reserve pg.reserve(num_of_slots, num_of_processors) process group needs to know slot count, and number of processors to reserve
  4. But the policy states n <= num_of_slots <= m may be reserve at a time.
  5. 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!

Dan J
  • 11
  • 1
  • What is the objective? Minimize the number of reservations? – Vaughn Cato Apr 27 '13 at 17:26
  • Objective is to maximize processor utilization and minimize reservations – Dan J Apr 27 '13 at 17:32
  • How do you define processor utilization? – Vaughn Cato Apr 27 '13 at 17:41
  • Are you trying to minimize the number of no-op tasks? – Vaughn Cato Apr 27 '13 at 17:43
  • Yes sir, to keep processors running on real tasks not excessive no-op tasks. – Dan J Apr 27 '13 at 17:53
  • So effectively you are trying to find the values of a and b such that the remainder of a/b is minimized and where the values of a and b are integers and are constrained to be within a certain range. Does that sound right? – Vaughn Cato Apr 27 '13 at 17:57
  • a and b if you;re referring to min and max slots? Then no. I am looking for number_of_slots, and number_of_processors to reserve given there is a restriction to their values... But to do so yes, we need to minimize the remainder of number_of_tasks/num_of_processors.. I hope I am clear – Dan J Apr 27 '13 at 18:12
  • If your only goals are to maximize processor utilization and minimize reservations (subject to the constraints), why not reserve (457, 1) in the first example? I suspect you also have a goal to minimize elapsed time. – Gareth Rees Apr 28 '13 at 00:21

0 Answers0