Skip to content

Commit ec3bfc1

Browse files
committed
round-robin scheduling
1 parent 63aad4d commit ec3bfc1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/tracedAtomic.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,21 @@ let mark_backtrack proc time state (last_read, last_write) =
313313
let map_subtract_set map set =
314314
IdMap.filter (fun key _ -> not (IdSet.mem key set)) map
315315

316+
let round_robin previous =
317+
let id = previous.run.proc_id in
318+
match IdSet.find_first_opt (fun j -> j > id) previous.enabled with
319+
| None -> IdSet.min_elt_opt previous.enabled
320+
| found -> found
321+
316322
let rec explore func time state (explored, state_planned) current_schedule (last_read, last_write) =
317323
let s = List.hd state in
318324
assert (IdMap.is_empty s.backtrack) ;
319325
let dones = ref IdSet.empty in
320326
begin match state_planned with
321327
| [] ->
322-
if IdSet.cardinal s.enabled > 0 then begin
323-
let p = IdSet.min_elt s.enabled in
328+
begin match round_robin s with
329+
| None -> assert (IdSet.is_empty s.enabled)
330+
| Some p ->
324331
let init_step = IdMap.find p s.procs in
325332
s.backtrack <- IdMap.singleton p [init_step] ;
326333
end

0 commit comments

Comments
 (0)