The Pedigree Project 0.1
scheduling-contract-test/contract.h
1#ifndef SCHEDULING_CONTRACT_H
2#define SCHEDULING_CONTRACT_H
3
4#include <errno.h>
5#include <pthread.h>
6#include <sched.h>
7#include <stdatomic.h>
8#include <stdint.h>
9#include <stdio.h>
10#include <time.h>
11
12#include <sys/types.h>
13
14#define SC_APP "/applications/scheduling-contract-test"
15#define CHECK(condition) \
16 do { \
17 if (!(condition)) { \
18 fprintf(stderr, "%s:%d: %s (errno=%d)\n", __FILE__, __LINE__, #condition, errno); \
19 failed = 1; \
20 goto out; \
21 } \
22 } while (0)
23
24struct sc_peer {
25 pid_t pid;
26 int command, report;
27};
28#define SC_PEER_INITIALIZER {.pid = -1, .command = -1, .report = -1}
29extern cpu_set_t sc_allowed;
30extern int sc_cpus[CPU_SETSIZE], sc_count;
31extern size_t sc_bytes, sc_page;
32extern _Thread_local unsigned sc_tls;
33int sc_init(int expected);
34int sc_pin(pid_t tid, int cpu);
35int sc_mask(pid_t tid, int cpu);
36int sc_sample(int cpu);
37int sc_register_syscall(long number, long a, long b, long c, long* result);
38int64_t sc_now(void);
39int sc_wait(atomic_uint* value, unsigned expected);
40int sc_wait_for_task_retirement(pid_t tid, const struct timespec* expected_interval);
41int sc_read(int fd, void* buffer, size_t length);
42int sc_write(int fd, const void* buffer, size_t length);
43int sc_send(int fd, char value);
44int sc_receive(int fd, char value);
45int sc_reap(pid_t pid, int milliseconds);
46int sc_spawn(struct sc_peer*, int (*body)(int, int, void*), void*);
47int sc_join(struct sc_peer*);
48void sc_cleanup(struct sc_peer*);
49int sc_api(void);
50int sc_placement(void);
51int sc_wakeups(void);
52int sc_lifecycle(void);
53int sc_permissions(void);
54int sc_exec(int argc, char** argv);
55int sc_input(void);
56int sc_input_exec(int argc, char** argv);
57#endif