model-net-sched.c 1.93 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright (C) 2014 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
 */

/* A scheduler interface for use by model-net. */

#include <assert.h>
#include <ross.h>

12
#include "model-net-sched-impl.h"
13 14 15 16
#include "codes/model-net-sched.h"
#include "codes/model-net-lp.h"
#include "codes/quicklist.h"

17 18 19 20 21
#define X(a,b,c) b,
char * sched_names [] = {
    SCHEDULER_TYPES
};
#undef X
22 23 24 25 26 27 28

/// general scheduler functions

void model_net_sched_init(
        enum sched_type type, 
        struct model_net_method *method,
        model_net_sched *sched){
29 30 31
    if (type >= MAX_SCHEDS){
        fprintf(stderr, "unknown scheduler type");
        abort();
32
    }
33 34 35 36
    else{
        sched->impl = sched_interfaces[type];
    }
    sched->type = type;
37 38 39 40 41 42
    sched->impl->init(method, &sched->dat);
}

int model_net_sched_next(
        tw_stime *poffset,
        model_net_sched *sched,
43
        void *rc_event_save,
44 45
        model_net_sched_rc *sched_rc,
        tw_lp *lp){
46
    return sched->impl->next(poffset, sched->dat, rc_event_save, sched_rc, lp);
47 48 49 50
}

void model_net_sched_next_rc(
        model_net_sched *sched,
51
        void *rc_event_save,
52 53
        model_net_sched_rc *sched_rc,
        tw_lp *lp) {
54
    sched->impl->next_rc(sched->dat, rc_event_save, sched_rc, lp);
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
}

void model_net_sched_add(
        model_net_request *req,
        int remote_event_size,
        void * remote_event,
        int local_event_size,
        void * local_event,
        model_net_sched *sched,
        model_net_sched_rc *sched_rc,
        tw_lp *lp){
    sched->impl->add(req, remote_event_size, remote_event, local_event_size,
            local_event, sched->dat, sched_rc, lp);
}

void model_net_sched_add_rc(
        model_net_sched *sched,
        model_net_sched_rc *sched_rc,
        tw_lp *lp){
    sched->impl->add_rc(sched->dat, sched_rc, lp);
}

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ft=c ts=8 sts=4 sw=4 expandtab
 */