52schedule_entry_debug_info(
const char *caller,
const struct schedule_entry *e)
86 if (e1->
tv.tv_sec < e2->
tv.tv_sec)
90 else if (e1->
tv.tv_sec > e2->
tv.tv_sec)
96 if (e1->
tv.tv_usec < e2->
tv.tv_usec)
100 else if (e1->
tv.tv_usec > e2->
tv.tv_usec)
110 else if (e1->
pri > e2->
pri)
184 else if (gp->
lt == p)
245 while (e->
lt || e->
gt)
344 schedule_entry_debug_info(
"schedule_add_modify", e);
394 schedule_entry_debug_info(
"schedule_find_least", e);
434schedule_find_earliest_wakeup(
struct schedule *s)
444schedule_debug_entry(
const struct schedule_entry *e,
int depth,
int *count,
struct timeval *least,
445 const struct timeval *min,
const struct timeval *max)
448 int maxdepth = depth;
482 if (least &&
tv_lt(&e->
tv, least))
487 d = schedule_debug_entry(e->
lt, depth + 1, count, least, min, &e->
tv);
493 d = schedule_debug_entry(e->
gt, depth + 1, count, least, &e->
tv, max);
504schedule_debug(
struct schedule *s,
int *count,
struct timeval *least)
511 max.tv_sec = 0x7FFFFFFF;
512 max.tv_usec = 0x7FFFFFFF;
518 return schedule_debug_entry(s->
root, 0, count, least, &min, &max);
524tv_randomize(
struct timeval *tv)
526 tv->tv_sec +=
random() % 100;
527 tv->tv_usec =
random() % 100;
533tv_randomize(
struct timeval *tv)
537 if ((choice & 0xFF) == 0)
539 tv->tv_usec += ((choice >> 8) & 0xFF);
543 prng_bytes((uint8_t *)tv,
sizeof(
struct timeval));
554 struct timeval least;
558 const struct status zz = z;
560 least.tv_sec = least.tv_usec = 0x7FFFFFFF;
564 maxlev = schedule_debug(s, &count, &least);
566 e = schedule_find_earliest_wakeup(s);
570 printf(
"Verification Phase count=%d maxlev=%d sru=%d ins=%d coll=%d ls=%d l=%s", count,
571 maxlev, zz.sru, zz.ins, zz.coll, zz.lsteps,
tv_string(&e->
tv, &
gc));
575 printf(
" [COMPUTED DIFFERENT MIN VALUES!]");
589 for (
i = 0;
i < size; ++
i)
595 array[
i] = array[src];
606 for (
i = 0;
i < indent; ++
i)
615 schedule_print_work(e->
lt, indent + 1);
616 schedule_print_work(e->
gt, indent + 1);
628 printf(
"*************************\n");
629 schedule_print_work(s->
root, 0);
647 printf(
"Creation/Insertion Phase\n");
649 for (
i = 0;
i < n; ++
i)
652 tv_randomize(&array[
i]->
tv);
658 schedule_randomize_array(array, n);
663 for (j = 1; j <= n_mod; ++j)
665 printf(
"Modification Phase Pass %d\n", j);
667 for (
i = 0;
i < n; ++
i)
669 e = schedule_find_earliest_wakeup(s);
671 tv_randomize(&e->
tv);
683 while ((e = schedule_find_earliest_wakeup(s)))
690 printf(
"S->ROOT is %s\n", s->
root ?
"NOT NULL" :
"NULL");
692 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(unsigned int 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