save works
This commit is contained in:
parent
ef95cea41f
commit
c1e42b1ee2
6 changed files with 202 additions and 108 deletions
|
|
@ -13,54 +13,18 @@
|
|||
#include "scheduler.h"
|
||||
#include "utils.h"
|
||||
|
||||
static uint64_t pick_job(xce_scheduler_t* sched)
|
||||
{
|
||||
static xce_sched_plugin_t* job_picker = NULL;
|
||||
uint64_t jobid = 0;
|
||||
|
||||
if (job_picker == NULL) {
|
||||
char* job_picker_plugin = "xce_sched_fcfs";
|
||||
|
||||
/* set job_pick_plugin according configuration */
|
||||
job_picker
|
||||
= kvmgr_lock(&(sched->plugins), job_picker_plugin, OBJREF_NOP);
|
||||
if ((job_picker == NULL) || (job_picker->job_elect_fn == NULL)) {
|
||||
/* something wrong */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (job_picker->job_elect_fn != NULL) {
|
||||
jobid = job_picker->job_elect_fn(job_picker);
|
||||
}
|
||||
|
||||
return jobid;
|
||||
}
|
||||
|
||||
static void* sched_job_picker(void* arg)
|
||||
{
|
||||
xce_scheduler_t* sched = (xce_scheduler_t*)arg;
|
||||
xce_sched_plugin_t* job_picker = NULL;
|
||||
xce_scheduler_t* sched = (xce_scheduler_t*)arg;
|
||||
char* job_pick_plugin = "xce_sched_fcfs";
|
||||
|
||||
xce_use(sched);
|
||||
|
||||
while (1) {
|
||||
int go = 0;
|
||||
uint64_t jobid = 0;
|
||||
|
||||
pthread_testcancel();
|
||||
|
||||
cbuf_get(&(sched->wbuf), &go);
|
||||
if (go == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* pick job */
|
||||
jobid = pick_job(sched);
|
||||
|
||||
cbuf_put(&(sched->jbuf), &jobid);
|
||||
job_picker = kvmgr_lock(&(sched->plugins), job_pick_plugin, OBJREF_NOP);
|
||||
if ((job_picker == NULL) || (job_picker->job_elect_fn == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return job_picker->job_elect_fn(job_picker);
|
||||
}
|
||||
|
||||
static xce_decision_t* calc_decision(xce_scheduler_t* sched, uint64_t jobid)
|
||||
|
|
@ -335,6 +299,20 @@ void sched_go(xce_scheduler_t* sched)
|
|||
return;
|
||||
}
|
||||
|
||||
void sched_begin_session(xce_scheduler_t* sched)
|
||||
{
|
||||
plugin_begin_session(sched);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void sched_end_session(xce_scheduler_t* sched)
|
||||
{
|
||||
plugin_end_session(sched);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int sched_add_job(xce_scheduler_t* sched, xce_sched_job_t* j)
|
||||
{
|
||||
return kvmgr_add(&(sched->jobs), (void*)j->jobid, j);
|
||||
|
|
@ -386,3 +364,5 @@ xce_sched_project_t* sched_get_project(xce_scheduler_t* sched, char* name)
|
|||
}
|
||||
|
||||
int sched_job_is_ready(xce_sched_job_t* j) { return 1; }
|
||||
|
||||
int sched_queue_is_ready(xce_sched_queue_t* q) { return 1; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue