working of scheduler to handle configuration

This commit is contained in:
Rongsong Shen 2025-12-26 15:22:21 +08:00
parent a46ea822c1
commit ae658c4a23
11 changed files with 99 additions and 45 deletions

View file

@ -11,8 +11,8 @@
typedef void* plugin_data_t;
/* hooker of plugin, the first parameter should be xce_sched_plugin_t */
typedef int (*plugin_update_config_hook_t)(void*, xce_conf4sched_t*,
xce_conf4sched_t*);
typedef int (*plugin_update_config_hook_t)(void*, xce_sched_config_t*,
xce_sched_config_t*);
typedef int (*plugin_update_queue_hook_t)(void*, xce_sched_queue_t*,
xce_sched_queue_t*);
typedef int (*plugin_update_job_hook_t)(void*, xce_sched_job_t*,
@ -62,7 +62,7 @@ typedef struct {
extern int plugin_register(void*, void*);
extern void plugin_unregister(void*);
extern int plugin_config_update(void*, xce_conf4sched_t*, xce_conf4sched_t*);
extern int plugin_config_update(void*, xce_sched_config_t*, xce_sched_config_t*);
extern int plugin_queue_update(void*, xce_sched_queue_t*, xce_sched_queue_t*);
extern int plugin_job_update(void*, xce_sched_job_t*, xce_sched_job_t*);
extern int plugin_worker_update(void*, xce_sched_worker_t*,

View file

@ -5,6 +5,7 @@
#include <stdint.h>
#include <stdlib.h>
#include "kvmgr.h"
#include "typemap.h"
#include "xce/types.h"
@ -54,15 +55,22 @@ typedef struct {
typedef struct {
char* name;
uint32_t status;
xce_val_t* res_avail; /* resources in worker */
xce_val_t* res_in_use; /* used resources in worker */
} xce_sched_worker_t;
typedef struct {
char* clustername;
resmgr_t resmgr;
} xce_sched_config_t;
extern xce_sched_job_t* make_sched_job(void*, xce_job_t*);
extern xce_sched_queue_t* make_sched_queue(void*, xce_queue_t*);
extern xce_sched_worker_t* make_sched_worker(void*, xce_worker_t*);
extern xce_sched_user_t* make_sched_user(void*, char*);
extern xce_sched_project_t* make_sched_project(void*, char*);
extern xce_sched_config_t* make_sched_config(void*, xce_conf4sched_t*);
extern void kill_sched_job(void*);
extern void kill_sched_queue(void*);
extern void kill_sched_worker(void*);

View file

@ -49,22 +49,22 @@ typedef struct {
link)))
typedef struct {
mylock_t lock;
int stop;
xcecli_ctx_t apictx;
xce_conf4sched_t* config;
kvmgr_t plugins;
dataq_t* pend_updates[2];
kvmgr_t jobs;
kvmgr_t queues;
kvmgr_t workers;
kvmgr_t users;
kvmgr_t projects;
pthread_t jobpicker;
pthread_t allocator;
cbuf_t wbuf; /* action to trigger scheduling */
cbuf_t jbuf; /* job picked for allocation */
cbuf_t decisions; /* scheduler decisions */
mylock_t lock;
int stop;
xcecli_ctx_t apictx;
xce_sched_config_t* config;
kvmgr_t plugins;
dataq_t* pend_updates[2];
kvmgr_t jobs;
kvmgr_t queues;
kvmgr_t workers;
kvmgr_t users;
kvmgr_t projects;
pthread_t jobpicker;
pthread_t allocator;
cbuf_t wbuf; /* action to trigger scheduling */
cbuf_t jbuf; /* job picked for allocation */
cbuf_t decisions; /* scheduler decisions */
} xce_scheduler_t;
extern int sched_init(xce_scheduler_t*, xce_client_config_t*,