26 #elif defined(_MSC_VER) 57 schedule_entry_debug_info(
const char *caller,
const struct schedule_entry *e)
95 if (e1->
tv.tv_sec < e2->
tv.tv_sec)
99 else if (e1->
tv.tv_sec > e2->
tv.tv_sec)
105 if (e1->
tv.tv_usec < e2->
tv.tv_usec)
109 else if (e1->
tv.tv_usec > e2->
tv.tv_usec)
119 else if (e1->
pri > e2->
pri)
193 else if (gp->
lt == p)
254 while (e->
lt || e->
gt)
353 schedule_entry_debug_info(
"schedule_add_modify", e);
404 schedule_entry_debug_info(
"schedule_find_least", e);
444 schedule_find_earliest_wakeup(
struct schedule *s)
457 struct timeval *least,
458 const struct timeval *min,
459 const struct timeval *max)
462 int maxdepth = depth;
496 if (least &&
tv_lt(&e->
tv, least))
501 d = schedule_debug_entry(e->
lt, depth+1, count, least, min, &e->
tv);
507 d = schedule_debug_entry(e->
gt, depth+1, count, least, &e->
tv, max);
518 schedule_debug(
struct schedule *s,
int *count,
struct timeval *least)
525 max.tv_sec = 0x7FFFFFFF;
526 max.tv_usec = 0x7FFFFFFF;
532 return schedule_debug_entry(s->
root, 0, count, least, &min, &max);
538 tv_randomize(
struct timeval *tv)
540 tv->tv_sec +=
random() % 100;
541 tv->tv_usec =
random() % 100;
547 tv_randomize(
struct timeval *tv)
551 if ((choice & 0xFF) == 0)
553 tv->tv_usec += ((choice >> 8) & 0xFF);
568 struct timeval least;
572 const struct status zz = z;
574 least.tv_sec = least.tv_usec = 0x7FFFFFFF;
578 maxlev = schedule_debug(s, &count, &least);
580 e = schedule_find_earliest_wakeup(s);
584 printf(
"Verification Phase count=%d maxlev=%d sru=%d ins=%d coll=%d ls=%d l=%s",
595 printf(
" [COMPUTED DIFFERENT MIN VALUES!]");
609 for (i = 0; i < size; ++i)
615 array [i] = array [src];
626 for (i = 0; i < indent; ++i)
639 schedule_print_work(e->lt, indent+1);
640 schedule_print_work(e->gt, indent+1);
652 printf(
"*************************\n");
653 schedule_print_work(s->
root, 0);
671 printf(
"Creation/Insertion Phase\n");
673 for (i = 0; i < n; ++i)
676 tv_randomize(&array[i]->tv);
682 schedule_randomize_array(array, n);
687 for (j = 1; j <= n_mod; ++j)
689 printf(
"Modification Phase Pass %d\n", j);
691 for (i = 0; i < n; ++i)
693 e = schedule_find_earliest_wakeup(s);
695 tv_randomize(&e->
tv);
707 while ((e = schedule_find_earliest_wakeup(s)))
714 printf(
"S->ROOT is %s\n", s->
root ?
"NOT NULL" :
"NULL");
716 for (i = 0; i < n; ++i)
static void schedule_set_pri(struct schedule_entry *e)
void schedule_remove_node(struct schedule *s, struct schedule_entry *e)
struct schedule_entry * earliest_wakeup
static void gc_free(struct gc_arena *a)
static void schedule_insert(struct schedule *s, struct schedule_entry *e)
#define ALLOC_ARRAY(dptr, type, n)
static bool check_debug_level(unsigned int level)
static int schedule_entry_compare(const struct schedule_entry *e1, const struct schedule_entry *e2)
struct schedule_entry * root
struct schedule * schedule_init(void)
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
static struct gc_arena gc_new(void)
#define ALLOC_OBJ_CLEAR(dptr, type)
void prng_bytes(uint8_t *output, int len)
struct schedule_entry * gt
static SERVICE_STATUS status
struct schedule_entry * schedule_find_least(struct schedule_entry *e)
void schedule_free(struct schedule *s)
const char * tv_string_abs(const struct timeval *tv, struct gc_arena *gc)
void schedule_remove_entry(struct schedule *s, struct schedule_entry *e)
static void schedule_rotate_up(struct schedule *s, struct schedule_entry *e)
static bool tv_le(const struct timeval *t1, const struct timeval *t2)
struct schedule_entry * parent
static void schedule_detach_parent(struct schedule *s, struct schedule_entry *e)
void schedule_add_modify(struct schedule *s, struct schedule_entry *e)
struct schedule_entry * lt
static bool tv_lt(const struct timeval *t1, const struct timeval *t2)
Garbage collection arena used to keep track of dynamically allocated memory.
long int get_random(void)
static bool tv_eq(const struct timeval *t1, const struct timeval *t2)