/** * preempter thread for each Java thread */ static void NONRETURNING jthread_preempter(void * obj) { l4_rt_preemption_t dw; l4_threadid_t src; l4_msgdope_t result; int error; l4_threadid_t self = l4_myself(); l4thread_started(obj); while (1) { /* wait for request */ error = l4_ipc_wait(&src, L4_IPC_SHORT_MSG, &dw.lh.low, &dw.lh.high, L4_IPC_NEVER, &result); if (error == 0 && leaflet.misshandler != NULL) { if (l4_tasknum_equal(self, src)) { switch(dw.p.type){ case L4_RT_PREEMPT_TIMESLICE: // LOG("TimeSlice "l4util_idfmt"/%d", l4util_idstr(src), dw.p.id); jthread_preemption(src, leaflet.wcetover); break; case L4_RT_PREEMPT_DEADLINE: // LOG("DeadLine "l4util_idfmt, l4util_idstr(src)); jthread_preemption(src, leaflet.deadover); break; default: LOG("unknown preemption"); } } } } }
static void btn_repeat(void *data) { l4thread_started(NULL); for (;;) { l4_umword_t code, new_code, repeat, new_repeat; l4_msgdope_t result; int error; error = l4_ipc_receive(evh_l4id, L4_IPC_SHORT_MSG, &code, &repeat, L4_IPC_NEVER, &result); error = l4_ipc_send (evh_l4id, L4_IPC_SHORT_MSG, 0, 0, L4_IPC_NEVER, &result); if (!repeat) continue; for (;;) { /* wait for around 250ms */ error = l4_ipc_receive(evh_l4id, L4_IPC_SHORT_MSG, &new_code, &new_repeat, l4_ipc_timeout(0,0,976,8), &result); if (error == L4_IPC_RETIMEOUT && !key_pending) { /* no new key in the meantime -- start repeat. * wait for round 30ms */ for (;;) { if (__shift) { switch (code) { case KEY_UP: _key_scroll(SDOWN, 1); break; case KEY_PAGEUP: _key_scroll(SDOWN, 20); break; case KEY_DOWN: _key_scroll(SUP, 1); break; case KEY_PAGEDOWN: _key_scroll(SUP, 20); break; default: _add_key_if_not_too_busy(code); } } else { /* send key */ _add_key_if_not_too_busy(code); } /* wait for key up or other key down */ error = l4_ipc_receive(evh_l4id, L4_IPC_SHORT_MSG, &new_code, &repeat, l4_ipc_timeout(0,0,546,6), &result); if (error != L4_IPC_RETIMEOUT || key_pending) { /* new key or key_up received -- break repeat. * tricky: fall through until next send */ break; } } } if (error == 0) { code = new_code; repeat = new_repeat; /* new key or key_up received -- only reply, do not repeat */ error = l4_ipc_send(evh_l4id, L4_IPC_SHORT_MSG, 0, 0, L4_IPC_NEVER, &result); if (repeat) continue; break; } else if (key_pending) { code = key_code; repeat = key_repeat; key_pending = 0; if (repeat) continue; break; } else { /* ??? */ LOG("btn_repeat: ipc error %02x", error); break; } } } }
/****************************************************************************** * evh_loop * * * * evh - IDL server loop * ******************************************************************************/ static void evh_loop(void *data) { l4thread_started(NULL); stream_io_server_loop(data); }