Skip to content

Commit

Permalink
WFQ Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KabirSamsi committed Nov 1, 2024
1 parent 36a745e commit cab9f10
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion progs/work_conserving/wfq_n_classes.sched
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
classes A, B, C;

policy = wfq[fifo[A], fifo[B], fifo[C]][1, 2, 3];
policy = wfq[(fifo[A], 1), (fifo[B], 2), (fifo[C], 3)];

return policy
2 changes: 1 addition & 1 deletion rio/frontend/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type stream =
(* Stream-To-Stream *)
| RoundRobin of stream list
| Strict of stream list
| WeightedFair of stream list * int list
| WeightedFair of (stream * int) list
(* Non-Work Conserving *)
| RateControlled of stream list
| LeakyBucket of stream list * int * int
Expand Down
2 changes: 2 additions & 0 deletions rio/frontend/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ rule token = parse
| "=" { EQUALS }
| "[" { LBRACKET }
| "]" { RBRACKET }
| "(" { LPAREN }
| ")" { RPAREN }
| "return" { RETURN }
| "classes" { CLASSES }
| "union" { UNION }
Expand Down
24 changes: 14 additions & 10 deletions rio/frontend/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
%token EQUALS
%token LBRACKET
%token RBRACKET
%token LPAREN
%token RPAREN
%token RETURN
%token CLASSES
%token UNION
Expand Down Expand Up @@ -71,14 +73,14 @@ set:

/* Policies */
policy:
| FIFO LBRACKET; pl = set; RBRACKET { Fifo pl }
| EDF LBRACKET; pl = set; RBRACKET { EarliestDeadline pl }
| SJN LBRACKET; pl = set; RBRACKET { ShortestJobNext pl }
| SRTF LBRACKET; pl = set; RBRACKET { ShortestRemaining pl }
| RR LBRACKET; pl = arglist; RBRACKET { RoundRobin pl }
| STRICT LBRACKET; pl = arglist; RBRACKET { Strict pl }
| WFQ LBRACKET; pl = arglist; RBRACKET; LBRACKET; wt = weight_list; RBRACKET { WeightedFair (pl, wt) }
| RCSP LBRACKET; pl = arglist; RBRACKET { RateControlled pl }
| FIFO LBRACKET; pl = set; RBRACKET { Fifo pl }
| EDF LBRACKET; pl = set; RBRACKET { EarliestDeadline pl }
| SJN LBRACKET; pl = set; RBRACKET { ShortestJobNext pl }
| SRTF LBRACKET; pl = set; RBRACKET { ShortestRemaining pl }
| RR LBRACKET; pl = arglist; RBRACKET { RoundRobin pl }
| STRICT LBRACKET; pl = arglist; RBRACKET { Strict pl }
| WFQ LBRACKET; pl = weighted_arglist; RBRACKET { WeightedFair pl }
| RCSP LBRACKET; pl = arglist; RBRACKET { RateControlled pl }

| LEAKY LBRACKET; LBRACKET;
pl = arglist; RBRACKET; COMMA;
Expand All @@ -99,8 +101,10 @@ setlist:
| pl = separated_list(COMMA, set) { pl }
arglist:
| pl = separated_list(COMMA, policy) { pl }
weight_list:
| pl = separated_list(COMMA, INT) { pl }
weighted_arglist:
| pl = separated_list(COMMA, weighted_arg) { pl }
weighted_arg:
| LPAREN; arg = separated_pair(policy, COMMA, INT); RPAREN { arg }

/* Declarations, assignments and returns */
internalcomp :
Expand Down
4 changes: 2 additions & 2 deletions rio/frontend/policy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ let rec sub cl st (p : Ast.policy) used =
| Fifo p -> Fifo (sub_set cl st p used)
| RoundRobin plst -> extract_subpol (RoundRobin (sub_plst cl st plst))
| Strict plst -> extract_subpol (Strict (sub_plst cl st plst))
| WeightedFair (plst, wts) ->
| WeightedFair wplst ->
extract_subpol
(WeightedFair
(sub_weighted_plst cl st
(List.combine plst (List.map float_of_int wts))))
(List.map (fun (x, y) -> (x, float_of_int y)) wplst)))
| _ -> failwith "ERROR: unsupported policy"

(* Look up any variables and substitute them in. *)
Expand Down

0 comments on commit cab9f10

Please sign in to comment.