1/**
2 * \file
3 * \brief Scheduler test
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#include <stdio.h>
16#include <barrelfish/barrelfish.h>
17#include <barrelfish/resource_ctrl.h>
18#include <bench/bench.h>
19
20#define ITERATIONS      1000000
21
22static const char *my_manifest =
23    "P 0 0 0 0 0 0\n"
24    "P 0 2 0 0 0 0\n";
25static rsrcid_t my_rsrc_id;
26
27int main(int argc, char *argv[])
28{
29    uint64_t start, now;
30
31    bench_init();
32
33    // Submit manifest
34    errval_t err = rsrc_manifest(my_manifest, &my_rsrc_id);
35    if(err_is_fail(err)) {
36        DEBUG_ERR(err, "rsrc_manifest");
37        abort();
38    }
39
40    // Enter best-effort phase
41    printf("Starting best-effort tests...\n");
42    err = rsrc_phase(my_rsrc_id, 0);
43    assert(err_is_ok(err));
44
45    // Check that we're running
46    start = bench_tsc();
47    for(int i = 0; i < ITERATIONS; i++) {
48        now = bench_tsc();
49    }
50    if(now - start < ITERATIONS) {
51        printf("Something's wrong with the time\n");
52        abort();
53    }
54
55    // Enter hard real-time phase
56    printf("Starting hard real-time tests...\n");
57    err = rsrc_phase(my_rsrc_id, 1);
58    assert(err_is_ok(err));
59
60    // Check that we don't miss a deadline
61    for(int i = 0; i < ITERATIONS; i++) {
62        start = bench_tsc();
63        /* slice =  */
64        /* while(bench_tsc() < start + DEADLINE); */
65        /* if(bench_tsc() > start + DEADLINE */
66        /*    start = bench_tsc(); */
67    }
68
69    return 0;
70}
71