1st workable scheduler with resource from controller

This commit is contained in:
Rongsong Shen 2025-12-31 15:48:33 +08:00
parent 780e9fb313
commit bef32ace38
8 changed files with 238 additions and 24 deletions

View file

@ -32,6 +32,7 @@ libxce_src = [ gen_srcs[0],
'ordq.c',
'preason.c',
'xcealloc.c',
'misc.c',
]
incdir = include_directories('../include')

101
src/lib/misc.c Normal file
View file

@ -0,0 +1,101 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "controller.capnp.h"
#include "misc.h"
#include "utils.h"
#include "xce/types.h"
int reset_resval(xce_val_t* val)
{
if (val == NULL) {
return -EINVAL;
}
switch (val->which) {
case Value_u_ivalue32:
val->u.ivalue32 = 0;
break;
case Value_u_uvalue32:
val->u.uvalue32 = 0;
break;
case Value_u_ivalue64:
val->u.ivalue64 = 0;
break;
case Value_u_uvalue64:
val->u.uvalue64 = 0;
break;
case Value_u_fvalue:
val->u.fvalue = 0.0;
break;
case Value_u_bvalue:
val->u.bvalue = 0;
break;
case Value_u_svalue:
val->u.svalue = NULL;
break;
default:
break;
}
return 1;
}
void free_res_account(xce_res_account_t* acct)
{
if (acct == NULL) {
return;
}
FREEUP(acct->resname);
FREEUP(acct);
}
void free_host_account(xce_host_account_t* acct)
{
if (acct == NULL) {
return;
}
if (acct->accounts != NULL) {
int i;
for (i = 0; i < acct->naccount; i++) {
free_res_account(acct->accounts[i]);
}
FREEUP(acct->accounts);
}
FREEUP(acct);
}
void free_job_account(xce_job_account_t* acct)
{
if (acct == NULL) {
return;
}
if (acct->accounts != NULL) {
int i;
for (i = 0; i < acct->nhosts; i++) {
free_host_account(acct->accounts[i]);
}
FREEUP(acct->accounts);
}
if (acct->accounts_shared != NULL) {
int i;
for (i = 0; i < acct->nres_shared; i++) {
free_res_account(acct->accounts_shared[i]);
}
FREEUP(acct->accounts_shared);
}
FREEUP(acct);
}

View file

@ -42,11 +42,12 @@ static xce_res_account_t* make_res_account(xce_alloc_t* alloc)
return NULL;
}
account->instid = alloc->instid;
account->resname = strdup(alloc->resname);
account->residx = -1;
account->used = 0.0;
account->reserved = alloc->value;
account->instid = alloc->instid;
account->resname = strdup(alloc->resname);
account->residx = -1;
account->used = 0.0;
account->reserved = alloc->value;
account->allocated = alloc->value;
return account;
}