52schedule_entry_debug_info(
const char *caller,
const struct schedule_entry *e)
68#if defined(__GNUC__) || defined(__clang__)
69#pragma GCC diagnostic push
70#pragma GCC diagnostic ignored "-Wconversion"
83#if defined(__GNUC__) || defined(__clang__)
84#pragma GCC diagnostic pop
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);
403 schedule_entry_debug_info(
"schedule_find_least", e);
443schedule_find_earliest_wakeup(
struct schedule *s)
453schedule_debug_entry(
const struct schedule_entry *e,
int depth,
int *count,
struct timeval *least,
454 const struct timeval *min,
const struct timeval *max)
457 int maxdepth = depth;
491 if (least &&
tv_lt(&e->
tv, least))
496 d = schedule_debug_entry(e->
lt, depth + 1, count, least, min, &e->
tv);
502 d = schedule_debug_entry(e->
gt, depth + 1, count, least, &e->
tv, max);
513schedule_debug(
struct schedule *s,
int *count,
struct timeval *least)
520 max.tv_sec = 0x7FFFFFFF;
521 max.tv_usec = 0x7FFFFFFF;
527 return schedule_debug_entry(s->
root, 0, count, least, &min, &max);
533tv_randomize(
struct timeval *tv)
535 tv->tv_sec +=
random() % 100;
536 tv->tv_usec =
random() % 100;
542tv_randomize(
struct timeval *tv)
546 if ((choice & 0xFF) == 0)
548 tv->tv_usec += ((choice >> 8) & 0xFF);
552 prng_bytes((uint8_t *)tv,
sizeof(
struct timeval));
563 struct timeval least;
567 const struct status zz = z;
569 least.tv_sec = least.tv_usec = 0x7FFFFFFF;
573 maxlev = schedule_debug(s, &count, &least);
575 e = schedule_find_earliest_wakeup(s);
579 printf(
"Verification Phase count=%d maxlev=%d sru=%d ins=%d coll=%d ls=%d l=%s", count,
580 maxlev, zz.sru, zz.ins, zz.coll, zz.lsteps,
tv_string(&e->
tv, &
gc));
584 printf(
" [COMPUTED DIFFERENT MIN VALUES!]");
598 for (
i = 0;
i < size; ++
i)
604 array[
i] = array[src];
615 for (
i = 0;
i < indent; ++
i)
624 schedule_print_work(e->
lt, indent + 1);
625 schedule_print_work(e->
gt, indent + 1);
637 printf(
"*************************\n");
638 schedule_print_work(s->
root, 0);
656 printf(
"Creation/Insertion Phase\n");
658 for (
i = 0;
i < n; ++
i)
661 tv_randomize(&array[
i]->
tv);
667 schedule_randomize_array(array, n);
672 for (j = 1; j <= n_mod; ++j)
674 printf(
"Modification Phase Pass %d\n", j);
676 for (
i = 0;
i < n; ++
i)
678 e = schedule_find_earliest_wakeup(s);
680 tv_randomize(&e->
tv);
692 while ((e = schedule_find_earliest_wakeup(s)))
699 printf(
"S->ROOT is %s\n", s->
root ?
"NOT NULL" :
"NULL");
701 for (
i = 0;
i < n; ++
i)
static void gc_free(struct gc_arena *a)
#define ALLOC_OBJ_CLEAR(dptr, type)
#define ALLOC_ARRAY(dptr, type, n)
static struct gc_arena gc_new(void)
void prng_bytes(uint8_t *output, int len)
long int get_random(void)
Data Channel Cryptography Module.
static SERVICE_STATUS status
static bool check_debug_level(msglvl_t level)
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
const char * tv_string_abs(const struct timeval *tv, struct gc_arena *gc)
static bool tv_le(const struct timeval *t1, const struct timeval *t2)
static bool tv_eq(const struct timeval *t1, const struct timeval *t2)
static bool tv_lt(const struct timeval *t1, const struct timeval *t2)
static void schedule_set_pri(struct schedule_entry *e)
static void schedule_rotate_up(struct schedule *s, struct schedule_entry *e)
void schedule_remove_entry(struct schedule *s, struct schedule_entry *e)
struct schedule * schedule_init(void)
void schedule_remove_node(struct schedule *s, struct schedule_entry *e)
struct schedule_entry * schedule_find_least(struct schedule_entry *e)
static int schedule_entry_compare(const struct schedule_entry *e1, const struct schedule_entry *e2)
void schedule_add_modify(struct schedule *s, struct schedule_entry *e)
static void schedule_insert(struct schedule *s, struct schedule_entry *e)
void schedule_free(struct schedule *s)
static void schedule_detach_parent(struct schedule *s, struct schedule_entry *e)
Garbage collection arena used to keep track of dynamically allocated memory.
struct schedule_entry * lt
struct schedule_entry * parent
struct schedule_entry * gt
struct schedule_entry * earliest_wakeup
struct schedule_entry * root