void schedule(void) { word_t action; action = (word_t)ksSchedulerAction; //printf("\n=======In schedule======\n"); if (action == (word_t)SchedulerAction_ChooseNewThread) { printf("in action_choosenewthread\n"); if (isRunnable(ksCurThread)) { tcbSchedEnqueue(ksCurThread); } if (CONFIG_NUM_DOMAINS > 1 && ksDomainTime == 0) { printf("will next domain\n"); nextDomain(); } printf("go to choosethread\n"); chooseThread(); ksSchedulerAction = SchedulerAction_ResumeCurrentThread; } else if (action != (word_t)SchedulerAction_ResumeCurrentThread) { if (isRunnable(ksCurThread)) { tcbSchedEnqueue(ksCurThread); } /* SwitchToThread */ switchToThread(ksSchedulerAction); ksSchedulerAction = SchedulerAction_ResumeCurrentThread; } }
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(); } } }
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; } } }
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 rescheduleRequired(void) { if (ksSchedulerAction != SchedulerAction_ResumeCurrentThread && ksSchedulerAction != SchedulerAction_ChooseNewThread) { tcbSchedEnqueue(ksSchedulerAction); } ksSchedulerAction = SchedulerAction_ChooseNewThread; }
void restart(tcb_t *target) { if (isBlocked(target)) { ipcCancel(target); setupReplyMaster(target); setThreadState(target, ThreadState_Restart); tcbSchedEnqueue(target); switchIfRequiredTo(target); } }
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(); } }
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(); } } }
void schedule(void) { word_t action; action = (word_t)ksSchedulerAction; if (action == (word_t)SchedulerAction_ChooseNewThread) { if (isRunnable(ksCurThread)) { tcbSchedEnqueue(ksCurThread); } if (ksDomainTime == 0) { nextDomain(); } chooseThread(); ksSchedulerAction = SchedulerAction_ResumeCurrentThread; } else if (action != (word_t)SchedulerAction_ResumeCurrentThread) { if (isRunnable(ksCurThread)) { tcbSchedEnqueue(ksCurThread); } /* SwitchToThread */ switchToThread(ksSchedulerAction); ksSchedulerAction = SchedulerAction_ResumeCurrentThread; } }
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); tcbSchedEnqueue(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"); } }