/*..........................................................................*/ void QF_run(void) { struct sched_param sparam; struct timeval timeout = { 0 }; /* timeout for select() */ QF_onStartup(); /* invoke startup callback */ /* try to maximize the priority of the ticker thread, see NOTE01 */ sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sparam) == 0) { /* success, this application has sufficient privileges */ } else { /* setting priority failed, probably due to insufficient privieges */ } QS_OBJ_DICTIONARY(&l_ticker); /* the QS dictionary for the ticker */ l_running = (uint8_t)1; while (l_running) { QF_TICK(&l_ticker); /* process a time tick */ timeout.tv_usec = 8000; select(0, 0, 0, 0, &timeout); /* sleep for the full tick , NOTE05 */ } QF_onCleanup(); /* invoke cleanup callback */ pthread_mutex_destroy(&QF_pThreadMutex_); }
/*..........................................................................*/ int_t QF_run(void) { struct sched_param sparam; struct timeval timeout = { 0 }; /* timeout for select() */ QF_onStartup(); /* invoke startup callback */ /* try to maximize the priority of the ticker thread, see NOTE01 */ sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sparam) == 0) { /* success, this application has sufficient privileges */ } else { /* setting priority failed, probably due to insufficient privieges */ } l_running = (int_t)1; while (l_running) { QF_onClockTick(); /* clock tick callback (must call QF_TICK_X()) */ timeout.tv_usec = l_tickUsec; /* set the desired tick interval */ select(0, 0, 0, 0, &timeout); /* sleep for the desired tick, NOTE05 */ } QF_onCleanup(); /* invoke cleanup callback */ pthread_mutex_destroy(&QF_pThreadMutex_); return (int_t)0; /* return success */ }
/*..........................................................................*/ void QF_run(void) { initialize(); QF_onStartup(); /* invoke startup callback */ for (;;) { /* enter the QK idle loop */ QK_onIdle(); /* invoke the on-idle callback */ } }
/*..........................................................................*/ int16_t QF_run(void) { QF_INT_DISABLE(); initialize(); QF_onStartup(); /* startup callback */ QF_INT_ENABLE(); for (;;) { /* the QK idle loop */ QK_onIdle(); /* invoke the QK on-idle callback */ } return (int16_t)0; /* this unreachable return is to make compiler happy */ }
/*..........................................................................*/ void QF_run(void) { uint8_t p; QActive *a; QEvent const *e; QF_INT_LOCK_KEY_ QF_onStartup(); /* startup callback */ for (;;) { /* the background loop */ QF_INT_LOCK_(); #if (QF_MAX_ACTIVE <= 8) if (QPSet8_notEmpty(&QF_readySet_)) { QPSet8_findMax(&QF_readySet_, p); #else if (QPSet64_notEmpty(&QF_readySet_)) { QPSet64_findMax(&QF_readySet_, p); #endif a = QF_active_[p]; QF_INT_UNLOCK_(); e = QActive_get_(a); /* get the next event for this AO */ QF_ACTIVE_DISPATCH_(&a->super, e); /* dispatch to the AO */ QF_gc(e); /* determine if event is garbage and collect it if so */ } else { #ifndef QF_INT_KEY_TYPE QF_onIdle(); /* see NOTE01 */ #else QF_onIdle(intLockKey_); /* see NOTE01 */ #endif /* QF_INT_KEY_TYPE */ } } } /*..........................................................................*/ void QActive_start(QActive *me, uint8_t prio, QEvent const *qSto[], uint32_t qLen, void *stkSto, uint32_t stkSize, QEvent const *ie) { Q_REQUIRE(((uint8_t)0 < prio) && (prio <= (uint8_t)QF_MAX_ACTIVE) && (stkSto == (void *)0)); /* does not need per-actor stack */ (void)stkSize; /* avoid the "unused parameter" compiler warning */ QEQueue_init(&me->eQueue, qSto, (QEQueueCtr)qLen);/* initialize QEQueue */ me->prio = prio; /* set the QF priority of this active object */ QF_add_(me); /* make QF aware of this active object */ QF_ACTIVE_INIT_(&me->super, ie); /* execute initial transition */ QS_FLUSH(); /* flush the trace buffer to the host */ }
/*..........................................................................*/ void QF_run(void) { QK_INT_LOCK_KEY_ QK_INT_LOCK_(); QK_currPrio_ = (uint8_t)0; /* set the priority for the QK idle loop */ QK_SCHEDULE_(); /* process all events produced so far */ QK_INT_UNLOCK_(); QF_onStartup(); /* startup callback */ for (;;) { /* the QK idle loop */ QK_onIdle(); /* invoke the QK on-idle callback */ } }
/*..........................................................................*/ int_t QF_run(void) { QF_onStartup(); /* startup callback */ /* raise the priority of this (main) thread to tick more timely */ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); l_running = (int_t)1; while (l_running) { Sleep(l_tickMsec); /* wait for the tick interval */ QF_onClockTick(); /* clock tick callback (must call QF_TICKX()) */ } QF_onCleanup(); /* cleanup callback */ QS_EXIT(); /* cleanup the QSPY connection */ //DeleteCriticalSection(&l_win32CritSect); return (int_t)0; /* return success */ }
/*..........................................................................*/ void QF_run(void) { l_running = (uint8_t)1; QF_onStartup(); /* startup callback */ /* raise the priority of this (main) thread to tick more timely */ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); QS_OBJ_DICTIONARY(&l_ticker); /* the QS dictionary for the ticker */ while (l_running) { QF_TICK(&l_ticker); /* process a time tick */ Sleep(l_tickMsec); /* wait for the tick interval */ } QF_onCleanup(); /* cleanup callback */ QS_EXIT(); /* cleanup the QSPY connection */ DeleteCriticalSection(&QF_win32CritSect_); }
/*..........................................................................*/ int_t QF_run(void) { /* CMSIS-RTX must be initialized and started from the starupt code */ Q_REQUIRE_ID(200, osKernelRunning()); /* call-back to the application to configure and start interrupts. * In the RTX port, QF_onStartup() typically also calls QF_setRtxTicker(). */ QF_onStartup(); /* CMSIS-RTOS starts thread execution with the function main(). * This main thread will continue executing after osKernelStart(). */ for (;;) { /* loop of the ticker thread */ QF_onRtxTicker(); /* call-back to the app to handle the tick */ osDelay(l_tickerPeriod); /* delay for the configurable period */ } #if defined (__GNUC__) return (int_t)0; /* dummy return to make the compiler happy */ #endif }
/*..........................................................................*/ void ucosTask(void *pdata) { (void)pdata; /* avoid the compiler warning about unused parameter */ QF_onStartup(); /* start interrupts including the clock tick, NOTE01 */ for (;;) { OSTimeDly(OS_TICKS_PER_SEC/10); /* sleep for 1/10 s */ if (kbhit()) { /* poll for a new keypress */ uint8_t key = (uint8_t)getch(); if (key == 0x1B) { /* is this the ESC key? */ QF_PUBLISH(Q_NEW(QEvt, TERMINATE_SIG), &l_kbdTask); } else { /* other key pressed */ Video_printNumAt(30, 13 + N_PHILO, VIDEO_FGND_YELLOW, key); } } } }
int_t QF_run(void) { QF_onStartup(); /* application-specific startup callback */ l_isRunning = true; /* QF is running */ /* set the ticker thread priority below normal to prevent * flooding other threads with time events when the machine * is very busy. */ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); while (l_isRunning) { Sleep(l_tickMsec); /* wait for the tick interval */ QF_onClockTick(); /* clock tick callback (must call QF_TICKX()) */ } QF_onCleanup(); /* cleanup callback */ QS_EXIT(); /* cleanup the QSPY connection */ //DeleteCriticalSection(&l_win32CritSect); //free all "fudged" event pools... return (int_t)0; /* return success */ }
/*..........................................................................*/ int_t QF_run(void) { QF_onStartup(); /* QF callback to configure and start interrupts */ OS_Start(); /* start embOS multitasking */ Q_ERROR_ID(100); /* OS_Start() should never return */ return (int_t)0; /* dummy return to make the compiler happy */ }