bool event_poll(int32_t ms) { int64_t remaining = ms; uint64_t end; bool result; if (ms > 0) { // Calculate end time in nanoseconds end = uv_hrtime() + ms * 1e6; } for (;;) { result = poll_uv_loop((int32_t)remaining); // Process queued events process_all_events(); if (ms > 0) { // Calculate remaining time in milliseconds remaining = (end - uv_hrtime()) / 1e6; } if (input_ready() || got_int) { // Bail out if we have pending input return true; } if (!result || (ms >= 0 && remaining <= 0)) { // Or if we timed out return false; } } }
void mac_controller_task(ADDRWORD_T data) { /* This is the only function running in an infinite loop. The function */ /* shall be suspended only when the processor is interrupted and shall */ /* be resumed once interrupt processing is over. */ while(1) { /* process all the pending events */ process_all_events(); /* Update the CPU utiltization test count */ update_cpu_util_count(); } }