-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include "jobs.h" | ||
|
||
int solver_sjf(struct job **job, struct job_clist *q, int32_t resources); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <queue.h> | ||
#include <errno.h> | ||
|
||
#include "evanix.h" | ||
#include "jobs.h" | ||
#include "solver_sjf.h" | ||
|
||
int solver_sjf(struct job **job, struct job_clist *q, int32_t resources) | ||
{ | ||
struct job *j; | ||
int cost_cur; | ||
|
||
struct job *selected = NULL; | ||
int cost_min = -1; | ||
|
||
CIRCLEQ_FOREACH (j, q, clist) { | ||
if (j->stale) | ||
continue; | ||
|
||
cost_cur = job_cost_recursive(j); | ||
if (cost_cur > resources) { | ||
job_stale_set(j); | ||
if (evanix_opts.solver_report) { | ||
printf("❌ refusing to build %s, cost: %d\n", | ||
j->drv_path, job_cost_recursive(j)); | ||
} | ||
} | ||
|
||
if (cost_min < 0 || cost_min > cost_cur) { | ||
selected = j; | ||
cost_min = cost_cur; | ||
} | ||
} | ||
|
||
*job = selected; | ||
return (cost_min < 0) ? -ESRCH : cost_min; | ||
} |