scheduler.h 1.5 KB

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