static void possibleSwitchTo(tcb_t* target, bool_t onSamePriority) { dom_t curDom, targetDom; prio_t curPrio, targetPrio; tcb_t *action; curDom = ksCurDomain; curPrio = ksCurThread->tcbPriority; targetDom = target->tcbDomain; targetPrio = target->tcbPriority; action = ksSchedulerAction; if (targetDom != curDom) { tcbSchedEnqueue(target); } else { if ((targetPrio > curPrio || (targetPrio == curPrio && onSamePriority)) && action == SchedulerAction_ResumeCurrentThread) { ksSchedulerAction = target; } else { tcbSchedEnqueue(target); } if (action != SchedulerAction_ResumeCurrentThread && action != SchedulerAction_ChooseNewThread) { rescheduleRequired(); } } }
static void handleYield(void) { tcbSchedDequeue(ksCurThread); tcbSchedAppend(ksCurThread); rescheduleRequired(); }
void epCancelAll(endpoint_t *epptr) { switch (endpoint_ptr_get_state(epptr)) { case EPState_Idle: break; default: { tcb_t *thread = TCB_PTR(endpoint_ptr_get_epQueue_head(epptr)); /* Make endpoint idle */ endpoint_ptr_set_state(epptr, EPState_Idle); endpoint_ptr_set_epQueue_head(epptr, 0); endpoint_ptr_set_epQueue_tail(epptr, 0); /* Set all blocked threads to restart */ for (; thread; thread = thread->tcbEPNext) { setThreadState (thread, ThreadState_Restart); tcbSchedEnqueue(thread); } rescheduleRequired(); break; } } }
void scheduleTCB(tcb_t *tptr) { if (tptr == ksCurThread && ksSchedulerAction == SchedulerAction_ResumeCurrentThread && !isRunnable(tptr)) { rescheduleRequired(); } }
void timerTick(void) { if (likely(isRunnable(ksCurThread))) { if (ksCurThread->tcbTimeSlice > 1) { ksCurThread->tcbTimeSlice--; } else { ksCurThread->tcbTimeSlice = CONFIG_TIME_SLICE; tcbSchedAppend(ksCurThread); rescheduleRequired(); } } if (CONFIG_NUM_DOMAINS > 1) { ksDomainTime--; if (ksDomainTime == 0) { rescheduleRequired(); } } }
void timerTick(void) { if (likely(thread_state_get_tsType(ksCurThread->tcbState) == ThreadState_Running)) { if (ksCurThread->tcbTimeSlice > 1) { ksCurThread->tcbTimeSlice--; } else { ksCurThread->tcbTimeSlice = CONFIG_TIME_SLICE; tcbSchedAppend(ksCurThread); rescheduleRequired(); } } if (CONFIG_NUM_DOMAINS > 1) { ksDomainTime--; if (ksDomainTime == 0) { rescheduleRequired(); } } }
void setPolicy(tcb_t *tptr, policy_t policy) { tcbSchedDequeue(tptr); tptr->tcbPolicy = policy; if (isRunnable(tptr)) { tcbSchedEnqueue(tptr); } if (tptr == ksCurThread) { rescheduleRequired(); } }
void setPriority(tcb_t *tptr, prio_t prio) { tcbSchedDequeue(tptr); tptr->tcbPriority = prio; if (isRunnable(tptr)) { tcbSchedEnqueue(tptr); } if (tptr == ksCurThread) { rescheduleRequired(); } }
void setDomain(tcb_t *tptr, dom_t dom) { tcbSchedDequeue(tptr); tptr->tcbDomain = dom; if (isRunnable(tptr)) { tcbSchedEnqueue(tptr); } if (tptr == ksCurThread) { rescheduleRequired(); } }
void timerTick(void) { /* printf("\n========in timertick==========\n"); */ if (likely(isRunnable(ksCurThread))) { if (ksCurThread->tcbTimeSlice > 1) { ksCurThread->tcbTimeSlice--; } else { ksCurThread->tcbTimeSlice = CONFIG_TIME_SLICE; tcbSchedAppend(ksCurThread); rescheduleRequired(); } } if (CONFIG_NUM_DOMAINS > 1) { /* printf("num domain is %d\n", CONFIG_NUM_DOMAINS); */ ksDomainTime--; /* printf("current domain is %d\n", ksCurDomain); printf("domain time is %d\n", ksDomainTime); */ if (ksDomainTime == 0) { /* printf("action is %d\n", ksSchedulerAction); */ rescheduleRequired(); } } }
static void possibleSwitchTo(tcb_t* target, bool_t onSamePriority) { prio_t curPrio, targetPrio; tcb_t *action; printf("====In possibleSwitchTo=====\n"); curPrio = ksCurThread->tcbPriority; targetPrio = target->tcbPriority; action = ksSchedulerAction; if (CONFIG_NUM_DOMAINS > 1) { dom_t curDom = ksCurDomain; dom_t targetDom = target->tcbDomain; printf("in config_num_domains>1\n"); printf("targetDom is %d\n", targetDom); printf("curDom is %d\n", curDom); printf("action is %x\n", action); tcbSchedEnqueue(target); if (targetDom != curDom) { tcbSchedEnqueue(target); } } else { printf("in else\n"); if ((targetPrio > curPrio || (targetPrio == curPrio && onSamePriority))&& action == SchedulerAction_ResumeCurrentThread) { printf("in first if: action will be %d\n", target); ksSchedulerAction = target; } else { printf("in else: will enquene target\n"); tcbSchedEnqueue(target); } if (action != SchedulerAction_ResumeCurrentThread && action != SchedulerAction_ChooseNewThread) { printf("in second if, will call rescheduleRequired\n"); rescheduleRequired(); } } }
void cancelAllSignals(notification_t *ntfnPtr) { if (notification_ptr_get_state(ntfnPtr) == NtfnState_Waiting) { tcb_t *thread = TCB_PTR(notification_ptr_get_ntfnQueue_head(ntfnPtr)); notification_ptr_set_state(ntfnPtr, NtfnState_Idle); notification_ptr_set_ntfnQueue_head(ntfnPtr, 0); notification_ptr_set_ntfnQueue_tail(ntfnPtr, 0); /* Set all waiting threads to Restart */ for (; thread; thread = thread->tcbEPNext) { setThreadState(thread, ThreadState_Restart); SCHED_ENQUEUE(thread); } rescheduleRequired(); } }
void epCancelBadgedSends(endpoint_t *epptr, word_t badge) { switch (endpoint_ptr_get_state(epptr)) { case EPState_Idle: case EPState_Recv: break; case EPState_Send: { tcb_t *thread, *next; tcb_queue_t queue = ep_ptr_get_queue(epptr); /* this is a de-optimisation for verification * reasons. it allows the contents of the endpoint * queue to be ignored during the for loop. */ endpoint_ptr_set_state(epptr, EPState_Idle); endpoint_ptr_set_epQueue_head(epptr, 0); endpoint_ptr_set_epQueue_tail(epptr, 0); for (thread = queue.head; thread; thread = next) { word_t b = thread_state_ptr_get_blockingIPCBadge( &thread->tcbState); next = thread->tcbEPNext; if (b == badge) { setThreadState(thread, ThreadState_Restart); tcbSchedEnqueue(thread); queue = tcbEPDequeue(thread, queue); } } ep_ptr_set_queue(epptr, queue); if (queue.head) { endpoint_ptr_set_state(epptr, EPState_Send); } rescheduleRequired(); break; } default: fail("invalid EP state"); } }
static void possibleSwitchTo(tcb_t* target, bool_t onSamePriority) { dom_t curDom, targetDom; prio_t curPrio, targetPrio; tcb_t *action; curDom = ksCurDomain; curPrio = ksCurThread->tcbPriority; targetDom = target->tcbDomain; targetPrio = target->tcbPriority; action = ksSchedulerAction; if (targetDom != curDom) { tcbSchedEnqueue(target); } else { //printf("in else\n"); if ((targetPrio > curPrio || (targetPrio == curPrio && onSamePriority))&& action == SchedulerAction_ResumeCurrentThread) { //printf("in first if: action will be %d\n", target); ksSchedulerAction = target; } else { //printf("in else: will enquene target\n"); tcbSchedEnqueue(target); } if (action != SchedulerAction_ResumeCurrentThread && action != SchedulerAction_ChooseNewThread) { //printf("in second if, will call rescheduleRequired\n"); rescheduleRequired(); } } }