model-net-sched.c 1.96 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
enum sched_type mn_sched_type = -1;

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

/// general scheduler functions

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

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

void model_net_sched_next_rc(
        model_net_sched *sched,
Jonathan Jenkins's avatar
Jonathan Jenkins committed
53
        void *rc_event_save,
54
55
        model_net_sched_rc *sched_rc,
        tw_lp *lp) {
Jonathan Jenkins's avatar
Jonathan Jenkins committed
56
    sched->impl->next_rc(sched->dat, rc_event_save, sched_rc, lp);
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
85
86
}

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
 */