/* * (c) 2008-2009 Adam Lackorzynski , * Alexander Warg , * Frank Mehnert , * Michael Hohmuth , * Jork Löser , * Lars Reuther * economic rights: Technische Universität Dresden (Germany) * This file is part of TUD:OS and distributed under the terms of the * GNU Lesser General Public License 2.1. * Please see the COPYING-LGPL-2.1 file for details. */ /* */ /***************************************************************************** * libl4util/src/sleep.c * * suspend thread * *****************************************************************************/ #include #include #include #include #include L4_CV void l4_sleep(int ms) { l4_timeout_t to; l4_msgtag_t tag; l4_utcb_t *u = l4_utcb(); if (ms != -1) /* calculate timeout */ to = l4_timeout(L4_IPC_TIMEOUT_NEVER,l4util_micros2l4to(ms * 1000)); else to = L4_IPC_NEVER; tag = l4_ipc_receive(L4_INVALID_CAP, u, to); if (l4_ipc_error(tag, u) != L4_IPC_RETIMEOUT) printf("l4_sleep(): IPC error %02x\n", l4_ipc_error_code(u)); } L4_CV void l4_usleep(int us) { l4_msgtag_t tag; l4_timeout_t to; l4_utcb_t *u = l4_utcb(); /* calculate timeout */ to = l4_timeout(L4_IPC_TIMEOUT_NEVER, l4util_micros2l4to(us)); tag = l4_ipc_sleep(to); if (l4_ipc_error(tag, u) != L4_IPC_RETIMEOUT) printf("l4_sleep(): IPC error %02x\n", l4_ipc_error_code(u)); }