Commit 94958c20 authored by Jonathan Jenkins's avatar Jonathan Jenkins

Correct resource stats in the case resource is unused

parent ee9e1f1a
...@@ -390,7 +390,6 @@ void resource_rev_handler( ...@@ -390,7 +390,6 @@ void resource_rev_handler(
void resource_finalize( void resource_finalize(
resource_state * ns, resource_state * ns,
tw_lp * lp){ tw_lp * lp){
/* Fill me in... */
struct qlist_head *ent; struct qlist_head *ent;
for (int i = 0; i < MAX_RESERVE+1; i++){ for (int i = 0; i < MAX_RESERVE+1; i++){
qlist_for_each(ent, &ns->pending[i]){ qlist_for_each(ent, &ns->pending[i]){
...@@ -409,6 +408,7 @@ void resource_finalize( ...@@ -409,6 +408,7 @@ void resource_finalize(
} }
written = sprintf(out_buf, "%lu", lp->gid); written = sprintf(out_buf, "%lu", lp->gid);
// compute peak resource usage
// TODO: wrap this up in the resource interface // TODO: wrap this up in the resource interface
for (int i = 0; i < ns->r.num_tokens+1; i++){ for (int i = 0; i < ns->r.num_tokens+1; i++){
written += sprintf(out_buf+written, " %lu", ns->r.max[i]-ns->r.min_avail[i]); written += sprintf(out_buf+written, " %lu", ns->r.max[i]-ns->r.min_avail[i]);
......
...@@ -18,11 +18,11 @@ void resource_init(uint64_t avail, resource *r){ ...@@ -18,11 +18,11 @@ void resource_init(uint64_t avail, resource *r){
r->max_all = avail; r->max_all = avail;
r->avail[0] = avail; r->avail[0] = avail;
r->max[0] = avail; r->max[0] = avail;
r->min_avail[0] = UINT64_MAX; r->min_avail[0] = avail;
for (int i = 1; i < MAX_RESERVE; i++){ for (int i = 1; i < MAX_RESERVE; i++){
r->avail[i] = 0; r->avail[i] = 0;
r->max[i] = 0; r->max[i] = 0;
r->min_avail[i] = UINT64_MAX; r->min_avail[i] = avail;
} }
} }
...@@ -119,6 +119,7 @@ int resource_reserve(uint64_t req, resource_token_t *tok, resource *r){ ...@@ -119,6 +119,7 @@ int resource_reserve(uint64_t req, resource_token_t *tok, resource *r){
*tok = ++(r->num_tokens); *tok = ++(r->num_tokens);
r->avail[*tok] = req; r->avail[*tok] = req;
r->max[*tok] = req; r->max[*tok] = req;
r->min_avail[*tok] = req;
r->max[0] -= req; r->max[0] -= req;
r->avail[0] -= req; r->avail[0] -= req;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment