/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1,result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7; SCHEDULING_CHECK_INIT(1); result_inst_1 = GetResource(RES_SCHEDULER); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK, result_inst_1); SCHEDULING_CHECK_INIT(2); result_inst_2 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_2); SCHEDULING_CHECK_INIT(3); result_inst_3 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_RESOURCE, result_inst_3); SCHEDULING_CHECK_INIT(4); result_inst_4 = ActivateTask(t3); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_4); SCHEDULING_CHECK_INIT(5); result_inst_5 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OS_RESOURCE, result_inst_5); SCHEDULING_CHECK_INIT(6); result_inst_6 = ReleaseResource(RES_SCHEDULER); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK, result_inst_6); SCHEDULING_CHECK_INIT(7); result_inst_7 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_7); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1,result_inst_2,result_inst_4,result_inst_5,result_inst_6,result_inst_7,result_inst_8; TaskStateType result_inst_3; SCHEDULING_CHECK_INIT(1); result_inst_1 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OK , result_inst_1); SCHEDULING_CHECK_INIT(2); result_inst_2 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(5,E_OK , result_inst_2); SCHEDULING_CHECK_INIT(6); result_inst_4 = GetTaskState(t2,&result_inst_3); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(6,WAITING , result_inst_3); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK , result_inst_4); SCHEDULING_CHECK_INIT(7); result_inst_5 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(7,E_OS_LIMIT , result_inst_5); SCHEDULING_CHECK_INIT(8); result_inst_6 = ChainTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(8,E_OS_LIMIT , result_inst_6); SCHEDULING_CHECK_INIT(9); result_inst_7= SetEvent(t2,Event2); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK , result_inst_7); SCHEDULING_CHECK_INIT(10); result_inst_8 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OK , result_inst_8); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_1, result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_9, result_inst_10; TickType result_inst_8; SCHEDULING_CHECK_INIT(2); result_inst_1 = SetAbsAlarm(Alarm1, 2, 2); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OK, result_inst_1); SCHEDULING_CHECK_INIT(3); result_inst_2 = SetAbsAlarm(Alarm1, 3, 0); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_STATE, result_inst_2); WaitActivationPeriodicAlarm(Alarm1); SCHEDULING_CHECK_INIT(4); result_inst_3 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(6,E_OK, result_inst_3); WaitActivationPeriodicAlarm(Alarm1); SCHEDULING_CHECK_INIT(7); result_inst_4 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_4); SCHEDULING_CHECK_INIT(10); result_inst_5 = CancelAlarm(Alarm1); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_5); SCHEDULING_CHECK_INIT(11); result_inst_6 = SetRelAlarm(Alarm1, 2, 0); SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OK, result_inst_6); SCHEDULING_CHECK_INIT(12); result_inst_7 = SetRelAlarm(Alarm1, 3, 0); SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_STATE, result_inst_7); SCHEDULING_CHECK_INIT(13); result_inst_9 = GetAlarm(Alarm1, &result_inst_8); SCHEDULING_CHECK_AND_EQUAL_INT_FIRST(13,2, result_inst_8); SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OK, result_inst_9); WaitActivationOneShotAlarm(Alarm1); SCHEDULING_CHECK_INIT(14); result_inst_10 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(15,E_OK, result_inst_10); }
/*test case:test the reaction of the system called with an activation of a task*/ static void test_t1_instance(void) { StatusType result_inst_2, result_inst_3, result_inst_4, result_inst_5, result_inst_6, result_inst_7, result_inst_8, result_inst_9, result_inst_10, result_inst_11; TaskStateType result_inst_3_5; SCHEDULING_CHECK_INIT(1); result_inst_2 = ActivateTask(INVALID_TASK); SCHEDULING_CHECK_AND_EQUAL_INT(1,E_OS_ID, result_inst_2); SCHEDULING_CHECK_INIT(2); result_inst_3 = GetTaskState(INVALID_TASK,&result_inst_3_5); SCHEDULING_CHECK_AND_EQUAL_INT(2,E_OS_ID, result_inst_3); SCHEDULING_CHECK_INIT(3); result_inst_4 = ChainTask(INVALID_TASK); SCHEDULING_CHECK_AND_EQUAL_INT(3,E_OS_ID, result_inst_4); SCHEDULING_CHECK_INIT(4); result_inst_5 = ActivateTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(4,E_OK, result_inst_5); SCHEDULING_CHECK_INIT(5); result_inst_6 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(9,E_OK, result_inst_6); SCHEDULING_CHECK_INIT(10); result_inst_7 = GetResource(RES_SCHEDULER); SCHEDULING_CHECK_AND_EQUAL_INT(10,E_OK, result_inst_7); SCHEDULING_CHECK_INIT(11); result_inst_8 = TerminateTask(); SCHEDULING_CHECK_AND_EQUAL_INT(11,E_OS_RESOURCE, result_inst_8); SCHEDULING_CHECK_INIT(12); result_inst_9 = ChainTask(t2); SCHEDULING_CHECK_AND_EQUAL_INT(12,E_OS_RESOURCE, result_inst_9); SCHEDULING_CHECK_INIT(13); result_inst_10 = Schedule(); SCHEDULING_CHECK_AND_EQUAL_INT(13,E_OS_RESOURCE, result_inst_10); SCHEDULING_CHECK_INIT(14); result_inst_11 = ReleaseResource(RES_SCHEDULER); SCHEDULING_CHECK_AND_EQUAL_INT(14,E_OK, result_inst_11); sendSoftwareIt(0, SOFT_IRQ0); SCHEDULING_CHECK_STEP(19); }
/*! Cancels the timer, if it is scheduled. */ void UserTimer::Cancel() { bigtime_t oldNextTime; bigtime_t oldInterval; return Schedule(B_INFINITE_TIMEOUT, 0, 0, oldNextTime, oldInterval); }
NS_IMETHODIMP IdleTaskRunner::Run() { if (!mCallback) { return NS_OK; } // Deadline is null when called from timer. TimeStamp now = TimeStamp::Now(); bool deadLineWasNull = mDeadline.IsNull(); bool didRun = false; bool allowIdleDispatch = false; if (deadLineWasNull || ((now + mBudget) < mDeadline)) { CancelTimer(); didRun = mCallback(mDeadline); // If we didn't do meaningful work, don't schedule using immediate // idle dispatch, since that could lead to a loop until the idle // period ends. allowIdleDispatch = didRun; } else if (now >= mDeadline) { allowIdleDispatch = true; } if (mCallback && (mRepeating || !didRun)) { Schedule(allowIdleDispatch); } else { mCallback = nullptr; } return NS_OK; }
/** ******************************************************************************* * @brief Unlock schedule * @param[in] None * @param[out] None * @retval None * * @par Description * @details This function is called to unlock schedule(i.e.enable schedule again) * * @note ******************************************************************************* */ void OsSchedUnlock(void) { if(OSSchedLock == 1) /* Is OSSchedLock == 0? */ { //__asm volatile ( "CPSID F\n"); // NEZ #if CFG_TASK_WAITTING_EN > 0 if(IsrReq == Co_TRUE) { RespondSRQ(); /* Respond service request */ } #endif /* Judge task state change or higher PRI task coming in */ if(TaskSchedReq == Co_TRUE) { Schedule(); /* Call task schedule */ } OSSchedLock = 0; //__asm volatile ( "CPSIE F\n"); // NEZ } else { OSSchedLock--; } }
/********************************************************************** * Set the task to the READY state and call the scheduler to jump to * another task if necessary. * * @param TaskID IN ID of the task * @return Status E_OS_ID if ID is not correct * never return otherwise **********************************************************************/ StatusType ActivateTask (TaskType TaskID) { unsigned char i; TaskRefType ptr_task; ptr_task = (TaskRefType)&tsk_1_state_ID; for (i = 0; i < MAX_TASK_NB; i++) { if ( (*ptr_task & MASK_ID) == TaskID ) { if ((*ptr_task & MASK_STATE) == SUSPENDED) { *ptr_task &= MASK_ID; *ptr_task += READY; Schedule(); } else { ptr_task = (TaskRefType)&tsk_1_activ_prio + i; if ((*ptr_task & MASK_ACTIV) < MASK_ACTIV) *ptr_task += 0x10; } return (E_OK); } ptr_task++; } return (E_OS_ID); }
void JobManager::EndJob(InternalJob::Pointer ptr_job, IStatus::Pointer result, bool notify) { Poco::Timestamp::TimeDiff rescheduleDelay(InternalJob::T_NONE); { Poco::ScopedLock<Poco::Mutex> lock ( m_mutex); // if the job is finishing asynchronously, there is nothing more to do for now if (result == Job::ASYNC_FINISH) return; //if job is not known then it cannot be done if (ptr_job->GetState() == Job::NONE) return; ptr_job->SetResult(result); ptr_job->SetProgressMonitor(IProgressMonitor::Pointer(nullptr)); ptr_job->SetThread(nullptr); rescheduleDelay = ptr_job->GetStartTime().epochMicroseconds(); InternalJob::Pointer sptr_job(ptr_job); ChangeState(sptr_job, Job::NONE); } //notify listeners outside sync block bool reschedule = m_active && rescheduleDelay > InternalJob::T_NONE && ptr_job->ShouldSchedule(); if (notify) m_JobListeners.Done(ptr_job.Cast<Job>(), result, reschedule); //reschedule the job if requested and we are still active if (reschedule) Schedule(ptr_job, rescheduleDelay, reschedule); }
// // Relinquishes the processor to the first user thread in the ready queue. // If there are no ready threads, the function returns immediately. // VOID UtYield() { if (!IsListEmpty(&ReadyQueue)) { RunningThread->State = READY; InsertTailList(&ReadyQueue, &RunningThread->Link); Schedule(); } }
// // Run the user threads. The operating system thread that calls this function // performs a context switch to a user thread and resumes execution only when // all user threads have exited. // VOID UtRun() { UTHREAD Thread; // Represents the underlying operating system thread. // // There can be only one scheduler instance running. // _ASSERTE(RunningThread == NULL); // // At least one user thread must have been created before calling run. // if (IsListEmpty(&ReadyQueue)) { return; } // // Switch to a user thread. // MainThread = &Thread; RunningThread = MainThread; Schedule(); // // When we get here, there are no more runnable user threads. // _ASSERTE(IsListEmpty(&ReadyQueue)); _ASSERTE(NumberOfThreads == 0); // // Allow another call to UtRun(). // RunningThread = NULL; MainThread = NULL; }
/* * Voluntarily give up the CPU to another thread. * Does nothing if no other threads are ready to run. */ void Yield(void) { Disable_Interrupts(); Make_Runnable(g_currentThread); Schedule(); Enable_Interrupts(); }
/* * Exit the current thread. * Calling this function initiates a context switch. */ void Exit(int exitCode) { struct Kernel_Thread* current = g_currentThread; if (Interrupts_Enabled()) Disable_Interrupts(); /* Thread is dead */ current->exitCode = exitCode; current->alive = false; /* Clean up any thread-local memory */ Tlocal_Exit(g_currentThread); /* Notify the thread's owner, if any */ Wake_Up(¤t->joinQueue); /* Remove the thread's implicit reference to itself. */ Detach_Thread(g_currentThread); /* * Schedule a new thread. * Since the old thread wasn't placed on any * thread queue, it won't get scheduled again. */ Schedule(); /* Shouldn't get here */ KASSERT(false); }
static void Main() { WindArrowLook wind_look; wind_look.Initialise(bold_font); WindowStyle with_border; with_border.Border(); WindWindow wind(wind_look); wind.Create(main_window, main_window.GetClientRect(), with_border); main_window.SetFullWindow(wind); auto timer = MakeLambdaTimer([&wind](){ SpeedVector _wind = wind.GetWind(); _wind.bearing = (_wind.bearing + Angle::Degrees(5)).AsBearing(); _wind.norm += 1; if (_wind.norm > 15) _wind.norm = 0; wind.SetWind(_wind); }); timer.Schedule(250); main_window.RunEventLoop(); timer.Cancel(); }
void Customer::Handler(BeginMsg &) { float x; x = Time + expdev(&idum)/mu; Schedule(x); // schedule the completion event }
static void Main() { HorizonLook horizon_look; horizon_look.Initialise(); WindowStyle with_border; with_border.Border(); HorizonWindow horizon(horizon_look); horizon.Create(main_window, main_window.GetClientRect(), with_border); main_window.SetFullWindow(horizon); auto timer = MakeLambdaTimer([&horizon](){ AttitudeState attitude; attitude.bank_angle_computed = true; attitude.pitch_angle_computed = true; attitude.bank_angle = Angle::Zero(); attitude.pitch_angle = Angle::Zero(); horizon.SetAttitude(attitude); }); timer.Schedule(250); main_window.RunEventLoop(); timer.Cancel(); }
// // Relinquishes the processor to the first user thread in the ready queue. // If there are no ready threads, the function returns immediately. // VOID UtYield () { if (!IsListEmpty(&ReadyQueue)) { SwitchCount++; InsertTailList(&ReadyQueue, &RunningThread->Link); Schedule(); } }
NS_IMETHODIMP nsOfflineCacheUpdateService::ScheduleUpdate(nsIURI *aManifestURI, nsIURI *aDocumentURI, nsIDOMWindow *aWindow, nsIOfflineCacheUpdate **aUpdate) { return Schedule(aManifestURI, aDocumentURI, nsnull, aWindow, aUpdate); }
void CPjTimerEntry::ConstructL(const pj_time_val *delay) { rtimer_.CreateLocal(); CActiveScheduler::Add(this); interval_left_ = PJ_TIME_VAL_MSEC(*delay); Schedule(); }
status_t sys_raw_send_msg_x( port_id hPort, uint32 nCode, const void *pBuffer, int nSize, const bigtime_t *pnTimeOut ) { int nError; nError = send_msg_x( hPort, nCode, pBuffer, nSize, *pnTimeOut ); Schedule(); return ( nError ); }
status_t sys_send_msg( port_id hPort, uint32 nCode, const void *pBuffer, int nSize ) { int nError; nError = send_msg_x( hPort, nCode, pBuffer, nSize, INFINITE_TIMEOUT ); Schedule(); return ( nError ); }
/********************************************************************** * Restore the kernel state and enable the Schedule function: * if a service like SetEvent has been called by an ISR then the service * didn't schedule when it's called but at the end of the ISR, thanks to * the LeaveISR function. * * @param void * @return void **********************************************************************/ void LeaveISR(void) { if (kernelState & SERVICES) { kernelState = kernel_copy; Schedule(); } kernelState = kernel_copy; }
void Initialize(const char * name, task_fn comain, int nthreads) { Initialize(nthreads); Schedule(name, [&]() -> void { comain(); ExitMain(); }, 0); EnterMain(); }
IBFRSwap::IBFRSwap(Type type, Real nominal, Date startDate, Period swapTenor, Period paymentTenor, Rate fixedRate, Rate rateSpread, const boost::shared_ptr<RepoChina>& iborIndex) :RepoCompoundingSwap(type, nominal, Schedule(startDate, startDate + swapTenor, paymentTenor, China(), ModifiedFollowing, ModifiedFollowing, DateGeneration::Backward, false), fixedRate, Actual365Fixed(), Schedule(startDate, startDate + swapTenor, paymentTenor, China(), ModifiedFollowing, ModifiedFollowing, DateGeneration::Backward, false), iborIndex, rateSpread, 0.0, Actual360(), Following) {}
// //////////////////////////////////////////////////////////////////////////// bool PacketReceiverAsyncMC::Run() { if (!RunImpl()) return(false); if (!is_running_) Schedule(); return(true); }
void Execute() { printf("Execute\n"); OtherBusiness1(); OtherBusiness2(); Schedule(); }
/** ******************************************************************************* * @brief Exit a ISR. * @param[in] None * @param[out] None * @retval None * * @par Description * @details This function is called when exit from a ISR. * * @note ******************************************************************************* */ void CoExitISR(void) { Dec8(&OSIntNesting); /* OSIntNesting decrease */ if( OSIntNesting == 0) { /* Is OSIntNesting == 0? */ if(TaskSchedReq == Co_TRUE) { OSSchedLock++; Schedule(); /* Call task schedule */ OSSchedLock--; } } }
// //////////////////////////////////////////////////////////////////////////// bool PacketSocketAsync::Run() { if (!RunImpl()) return(false); if (!is_running_) Schedule(); return(true); }
// //////////////////////////////////////////////////////////////////////////// bool PacketReceiverAsyncMC::RecvFromAsync( const boost::system::error_code &error, std::size_t bytes_received) { if (RecvFromAsyncImpl(error, bytes_received)) { Schedule(); return(true); } return(false); }
void RunContinuations() { POMDOG_ASSERT(!scheduler.expired()); auto sharedScheduler = scheduler.lock(); POMDOG_ASSERT(sharedScheduler); for (auto & continuation : continuations) { sharedScheduler->Schedule(std::move(continuation)); } continuations.clear(); }