void DispatcherPrivate::run_steps() { int now = _wall.read_us(); TRACE(("run_steps(): starting, now=%i.\r\n", now)); clear_signals(); clear_normal_step(); run_tasks(StateCommited); #ifdef DISPATCH_DEBUG int tick_before = get_tick(); #endif // no commited nodes left, see if we have enough time for a normal loop for(;;) { int tdiff = wall_diff(now); if(tdiff >= _clock_multiplier) break; run_tasks(StateNormal | StateUrgent); DelayedThread::signal_wait(SIGNAL_CHANGED, (_clock_multiplier - tdiff) / 1000); } run_tasks(StateUrgent); TRACE(("Dispatcher wait end (diff=%i, tdiff=%i).\r\n", wall_diff(now), get_tick() - tick_before)); }
void Start_OS() { while(1) { run_tasks(); } }
/*the ticker thread function that executes the filters */ void * ms_ticker_run(void *arg) { MSTicker *s=(MSTicker*)arg; int lastlate=0; int precision=2; int late; precision = set_high_prio(s); s->thread_id = ms_thread_self(); s->ticks=1; s->orig=s->get_cur_time_ptr(s->get_cur_time_data); ms_mutex_lock(&s->lock); while(s->run){ uint64_t late_tick_time=0; s->ticks++; /*Step 1: run the graphs*/ { #if TICKER_MEASUREMENTS MSTimeSpec begin,end;/*used to measure time spent in processing one tick*/ double iload; ms_get_cur_time(&begin); #endif run_tasks(s); run_graphs(s,s->execution_list,FALSE); #if TICKER_MEASUREMENTS ms_get_cur_time(&end); iload=100*((end.tv_sec-begin.tv_sec)*1000.0 + (end.tv_nsec-begin.tv_nsec)/1000000.0)/(double)s->interval; s->av_load=(smooth_coef*s->av_load)+((1.0-smooth_coef)*iload); #endif } ms_mutex_unlock(&s->lock); /*Step 2: wait for next tick*/ s->time+=s->interval; late=s->wait_next_tick(s->wait_next_tick_data,s->time); if (late>s->interval*5 && late>lastlate){ ms_warning("%s: We are late of %d miliseconds.",s->name,late); late_tick_time=ms_get_cur_time_ms(); } lastlate=late; ms_mutex_lock(&s->lock); if (late_tick_time){ s->late_event.lateMs=late; s->late_event.time=late_tick_time; } s->late_event.current_late_ms = late; } ms_mutex_unlock(&s->lock); unset_high_prio(precision); ms_message("%s thread exiting",s->name); ms_thread_exit(NULL); s->thread_id = 0; return NULL; }
void main() { __disable_interrupt(); init_core(); init_device(); init_wdt(); __enable_interrupt(); microrl_init (pointerMicrorl, &serprintf); microrl_set_execute_callback (pointerMicrorl, execute); microrl_set_complete_callback (pointerMicrorl, complet); microrl_set_sigint_callback (pointerMicrorl, sigint); init_app_settings(); print_revision(); DEBUG_PRINTF("FlashMem: %s %s\n\r", get_family_desc_at25df(), get_density_desc_at25df()); enable_default_lis3dh(); init_tasks(); init_reco_drift(); init_can_j1939(); DEBUG_PRINTF("\r\n\r\n"); while (1) { if (pointerRingBuff->size(pointerRingBuff) > 0) { const uint8_t data = pointerRingBuff->get(pointerRingBuff); if (!get_proto_type()) { microrl_insert_char (pointerMicrorl, data); } else { sdp_insert_char(data); } } poll_can_msg(); run_tasks(); clear_wdt(); } }
executor_thread_pool::executor_thread_pool( instrumentation::instrumentation & instr, const config & conf) : task_guague_(instr.add_gauge(k_exec_pool_service, k_exec_pool_desc)), finished_threads_(conf.executor_pool_size, 0), next_thread_(0), tasks_(conf.executor_pool_size) { auto run_fn = [=](const int i) { run_tasks(i); }; for (size_t i = 0; i < conf.executor_pool_size; i++) { tasks_[i].set_capacity(k_max_queue_size); threads_.push_back(std::move(std::thread(run_fn, i))); } }
/* * Do mad wild shit that makes us metric boatloads of cash money */ int main(int argc, char** argv) { ugly_init(99); if (argc < 2) { DLOG("(pass a mq host as argument, otherwise we use localhost)\n"); setup_mq("localhost"); } else { DLOG("Connecting to %s\n", argv[1]); setup_mq(argv[1]); } if (argc < 3) { key = "karl_loves_you"; DLOG("using default shared key of %s\n", key); } else { key = argv[2]; DLOG("using supplied shared key of %s\n", key); } while (1) { run_tasks(); } return (EXIT_SUCCESS); }