Closed ezhang887 closed 4 years ago
Round-robin pseudocode (@andyclee ):
func get_job():
N := num_queues
if N = 0:
return Empty
for i in {0, ..., N-1}:
idx := (round_robin_idx + i) % N
if queues[idx] is not empty:
round_robin_idx := (idx + 1) % N
return queues[idx].pop()
return Empty
Resolves #21.
Replaces the current global
queue
with a wrapper around it that contains multiplequeues
internally (called MultiQueue).The
MultiQueue
contains one queue per class. When pushing into theMultiQueue
, thecourse_id
will also need to be specified to indicate which internal queue to push into. When pulling from theMultiQueue
, it will round-robin between its internal queues, so starvation should not occur.To easily have access to the
course_id
when pushing into theMultiQueue
, I added it as a field to theGradingRun
model and dao. Also, the queues for each class are added into theMultiQueue
here.