model-net-sched.c 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * 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>

#include "codes/model-net-sched.h"
#include "codes/model-net-lp.h"
14
#include "model-net-sched-impl.h"
15 16
#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

/// general scheduler functions

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

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

void model_net_sched_next_rc(
        model_net_sched *sched,
52 53
        const void *rc_event_save,
        const model_net_sched_rc *sched_rc,
54
        tw_lp *lp) {
55
    sched->impl->next_rc(sched->dat, rc_event_save, sched_rc, lp);
56 57 58
}

void model_net_sched_add(
59
        const model_net_request *req,
60
        const mn_sched_params * sched_params,
61 62 63 64 65 66 67
        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){
68
    sched->impl->add(req, sched_params, remote_event_size, remote_event,
69
            local_event_size, local_event, sched->dat, sched_rc, lp);
70 71 72 73
}

void model_net_sched_add_rc(
        model_net_sched *sched,
74
        const model_net_sched_rc *sched_rc,
75 76 77 78
        tw_lp *lp){
    sched->impl->add_rc(sched->dat, sched_rc, lp);
}

79 80 81 82
void model_net_sched_set_default_params(mn_sched_params *sched_params){
    sched_params->prio = -1;
}

83 84 85 86 87 88 89 90
/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ft=c ts=8 sts=4 sw=4 expandtab
 */