Go to the documentation of this file.
53 schedule_entry_debug_info(
const char *caller,
const struct schedule_entry *e)
91 if (e1->
tv.tv_sec < e2->
tv.tv_sec)
95 else if (e1->
tv.tv_sec > e2->
tv.tv_sec)
101 if (e1->
tv.tv_usec < e2->
tv.tv_usec)
105 else if (e1->
tv.tv_usec > e2->
tv.tv_usec)
115 else if (e1->
pri > e2->
pri)
189 else if (gp->
lt == p)
250 while (e->
lt || e->
gt)
349 schedule_entry_debug_info(
"schedule_add_modify", e);
400 schedule_entry_debug_info(
"schedule_find_least", e);
440 schedule_find_earliest_wakeup(
struct schedule *s)
453 struct timeval *least,
454 const struct timeval *min,
455 const struct timeval *max)
458 int maxdepth = depth;
492 if (least &&
tv_lt(&e->
tv, least))
497 d = schedule_debug_entry(e->
lt, depth+1, count, least, min, &e->
tv);
503 d = schedule_debug_entry(e->
gt, depth+1, count, least, &e->
tv, max);
514 schedule_debug(
struct schedule *s,
int *count,
struct timeval *least)
521 max.tv_sec = 0x7FFFFFFF;
522 max.tv_usec = 0x7FFFFFFF;
528 return schedule_debug_entry(s->
root, 0, count, least, &min, &max);
534 tv_randomize(
struct timeval *tv)
536 tv->tv_sec +=
random() % 100;
537 tv->tv_usec =
random() % 100;
543 tv_randomize(
struct timeval *tv)
547 if ((choice & 0xFF) == 0)
549 tv->tv_usec += ((choice >> 8) & 0xFF);
553 prng_bytes((uint8_t *)tv,
sizeof(
struct timeval));
564 struct timeval least;
568 const struct status zz = z;
570 least.tv_sec = least.tv_usec = 0x7FFFFFFF;
574 maxlev = schedule_debug(s, &count, &least);
576 e = schedule_find_earliest_wakeup(s);
580 printf(
"Verification Phase count=%d maxlev=%d sru=%d ins=%d coll=%d ls=%d l=%s",
591 printf(
" [COMPUTED DIFFERENT MIN VALUES!]");
605 for (i = 0; i < size; ++i)
611 array [i] = array [src];
622 for (i = 0; i < indent; ++i)
635 schedule_print_work(e->
lt, indent+1);
636 schedule_print_work(e->
gt, indent+1);
648 printf(
"*************************\n");
649 schedule_print_work(s->
root, 0);
667 printf(
"Creation/Insertion Phase\n");
669 for (i = 0; i < n; ++i)
672 tv_randomize(&array[i]->
tv);
678 schedule_randomize_array(array, n);
683 for (j = 1; j <= n_mod; ++j)
685 printf(
"Modification Phase Pass %d\n", j);
687 for (i = 0; i < n; ++i)
689 e = schedule_find_earliest_wakeup(s);
691 tv_randomize(&e->
tv);
703 while ((e = schedule_find_earliest_wakeup(s)))
710 printf(
"S->ROOT is %s\n", s->
root ?
"NOT NULL" :
"NULL");
712 for (i = 0; i < n; ++i)
struct schedule_entry * lt
static struct gc_arena gc_new(void)
void schedule_remove_node(struct schedule *s, struct schedule_entry *e)
const char * tv_string_abs(const struct timeval *tv, struct gc_arena *gc)
long int get_random(void)
void prng_bytes(uint8_t *output, int len)
struct schedule_entry * schedule_find_least(struct schedule_entry *e)
struct schedule_entry * earliest_wakeup
struct schedule_entry * gt
static void schedule_rotate_up(struct schedule *s, struct schedule_entry *e)
void schedule_add_modify(struct schedule *s, struct schedule_entry *e)
static void schedule_detach_parent(struct schedule *s, struct schedule_entry *e)
static bool tv_le(const struct timeval *t1, const struct timeval *t2)
static void schedule_set_pri(struct schedule_entry *e)
struct schedule_entry * parent
void schedule_remove_entry(struct schedule *s, struct schedule_entry *e)
Garbage collection arena used to keep track of dynamically allocated memory.
static bool tv_lt(const struct timeval *t1, const struct timeval *t2)
static bool check_debug_level(unsigned int level)
struct schedule * schedule_init(void)
static SERVICE_STATUS status
static void gc_free(struct gc_arena *a)
static int schedule_entry_compare(const struct schedule_entry *e1, const struct schedule_entry *e2)
static void schedule_insert(struct schedule *s, struct schedule_entry *e)
#define ALLOC_OBJ_CLEAR(dptr, type)
static bool tv_eq(const struct timeval *t1, const struct timeval *t2)
#define ALLOC_ARRAY(dptr, type, n)
struct schedule_entry * root
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
void schedule_free(struct schedule *s)