void user_sync_init(struct user_sync_state *u) { u->mutex_size = 0; Q_INIT_HEAD(&u->mutexes); u->yield_progress = NOTHING_INTERESTING; u->xchg_count = 0; }
void sched_init(struct sched_state *s) { Q_INIT_HEAD(&s->rq); Q_INIT_HEAD(&s->dq); s->num_agents = 0; s->most_agents_ever = 0; s->guest_init_done = false; /* must be before kern_init_threads */ kern_init_threads(s, agent_fork); s->cur_agent = agent_by_tid_or_null(&s->rq, kern_get_first_tid()); if (s->cur_agent == NULL) s->cur_agent = agent_by_tid(&s->dq, kern_get_first_tid()); s->last_agent = NULL; s->last_vanished_agent = NULL; s->schedule_in_flight = NULL; s->delayed_in_flight = false; s->just_finished_reschedule = false; s->entering_timer = false; s->voluntary_resched_tid = -1; s->voluntary_resched_stack = NULL; }
/* register a malloced chunk as belonging to a particular mutex. * will add mutex to the list of all mutexes if it's not already there. */ void learn_malloced_mutex_structure(struct user_sync_state *u, unsigned int lock_addr, unsigned int chunk_addr, unsigned int chunk_size) { struct mutex *mp; assert(lock_addr != -1); Q_SEARCH(mp, &u->mutexes, nobe, mp->addr == (unsigned int)lock_addr); if (mp == NULL) { lsprintf(DEV, "created user mutex 0x%x (%u others)\n", lock_addr, Q_GET_SIZE(&u->mutexes)); mp = MM_XMALLOC(1, struct mutex); mp->addr = (unsigned int)lock_addr; Q_INIT_HEAD(&mp->chunks); Q_INSERT_FRONT(&u->mutexes, mp, nobe); }
/** @brief Function to initialise the condition variable * * Initialise the condition variables to defaut values * * @param cv condition variable that needs to be initialised * @return 1 on success , -1 on failure */ int cond_init (cond_t * cv) { assert (cv != NULL); if (cv->status == COND_EXIST) { lprintf("Condition variable already exists "); return COND_VAR_SUCC; } spin_lock_init (&cv->spinlock); cv->tid = DEFAULT_TID; cv->status = COND_EXIST; Q_INIT_HEAD (&cv->waiting_list); return COND_VAR_SUCC; }
// initializes the access mutex void initBlockList() { Q_INIT_HEAD(&blockList); allBlocks = (Block**)calloc(2, sizeof(Block*)); allBlockSize = 2; }
void arbiter_init(struct arbiter_state *r) { Q_INIT_HEAD(&r->choices); }