-
Notifications
You must be signed in to change notification settings - Fork 62
KernelTime
#include <time.h>
unix time()
- just the same old true unix time(). not recommended, of course
bigtime_t hal_system_time(void);
- useconds from kernel boot
bigtime_t hal_local_time(void);
- absolute time in useconds - NB! Base?
void hal_sleep_msec( int miliseconds );
- sleep (by switching to another thread) for given time. (In hal.h)
void phantom_spinwait(int millis);
- wait some mseconds by spinning (not giving CPU away) - note that you have to disable interrupts to wait EXACTLY for given time.
void tenmicrosec(void);
- wait by spinning, ~10 microsec
typedef bigtime_t polled_timeout_t;
void set_polled_timeout( polled_timeout_t *timer, bigtime_t timeout_uSec );
bool check_polled_timeout( polled_timeout_t *timer );
Use set_polled_timeout() to setup timeout (in microseconds). Use check_polled_timeout() to find out if time is passed. Note that interrupts must be enabled. This call depends on system timer interrupt granularity. (10 msec?)
Call function after timeout from timer interrupt.
void phantom_request_timed_call( timedcall_t *entry, u_int32_t flags );
void phantom_request_timed_func( timedcall_func_t f, void *arg, int msecLater, u_int32_t flags );
timedcall_t is:
timedcall_func_t f;
- func to call
void *arg;
- arg to pass to f
long msecLater;
- milliseconds to pass before call
flags are:
- TIMEDCALL_FLAG_PERIODIC - func will be called periodically
- TIMEDCALL_FLAG_AUTOFREE - entry will be freed automatically
NB! Call is done in timer interrupt! Be quick! Don't attempt to sleep (mutex/cond) or call functions that sleep.
NB! It is possible for callout to happen BEFORE the return from this function.
void phantom_request_cond_signal( int msec, hal_cond_t *cond);
void phantom_request_cond_broadcast( int msec, hal_cond_t *cond);
TODO
void phantom_request_timed_thread_wake( int tid, long timeMsec );
Implement copy of these, but working on separate thread.
Name is historical. Call function agfter timeout. Function is called in thread context, so it can call functions that block briefly (such as malloc/free). Still you can't sleep for long.
int set_net_timer(net_timer_event *e, unsigned int delay_ms, net_timer_callback callback, void *args, int flags);
int cancel_net_timer(net_timer_event *e);
:: Home :: RoadMap :: History :: ChangeLog :: ScreenShots :: Phantom Developer's Guide