blob: be4d7232049a5b8f69874092d7bbdd44f737c5db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* scheduler.h
* Scheduler
*
* Matej Pfajfar <mp292@cam.ac.uk>
*/
/*
* Changes :
* $Log$
* Revision 1.1 2002/06/26 22:45:50 arma
* Initial revision
*
* Revision 1.2 2002/03/28 10:49:07 badbytes
* Renamed get_trigger() to sched_trigger().
*
* Revision 1.1 2002/03/28 10:36:55 badbytes
* A generic scheduler.
*
*/
#ifndef __SCHEDULER_H
#include <sys/time.h>
typedef struct
{
struct timeval last;
struct timeval interval;
void *prev;
void *next;
} sched_entry_t;
typedef struct
{
sched_entry_t *entries;
} sched_t;
/* create a new scheduler */
sched_t *new_sched();
/* delete a scheduler from memory */
void free_sched(sched_t *sched);
/* add a new item to the scheduler */
int add_sched_entry(sched_t *sched, struct timeval last, struct timeval interval);
/* remove an item from the scheduler */
int remove_sched_entry(sched_t *sched, struct timeval last, struct timeval interval);
/* update an existing item with new values */
int update_sched_entry(sched_t *sched, struct timeval old_last, struct timeval old_interval, struct timeval new_last, struct timeval new_interval);
/* get the time interval from now until the next time an item needs to be serviced */
int sched_trigger(sched_t *sched, struct timeval **result);
/* compare two scheduler entries (returns 1 if entry1 >= entry2, 0 otherwise */
int sched_entry_geq(struct timeval last1, struct timeval interval1, struct timeval last2, struct timeval interval2);
# define __SCHEDULER_H
#endif
|