28 #include <sys/syscall.h> 36 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_LIB 49 #define TIMER_SIGNO SIGRTMIN 72 return syscall(SYS_gettid);
115 if (!tid_tlist_is_empty(&loc->
tlo_tids)) {
145 tid_tlink_init_at_tail(tt, &loc->
tlo_tids);
167 tid_tlink_del_fini(tt);
187 se.sigev_value.sival_ptr = timer;
188 if (timer->
t_tid == 0) {
189 se.sigev_notify = SIGEV_SIGNAL;
191 se.sigev_notify = SIGEV_THREAD_ID;
192 se._sigev_un._tid = timer->
t_tid;
208 rc = timer_delete(posix_timer);
231 struct itimerspec ts;
232 struct itimerspec ots;
238 ts.it_interval.tv_sec = 0;
239 ts.it_interval.tv_nsec = 0;
243 rc = timer_settime(timer->
t_ptimer, TIMER_ABSTIME, &ts, &ots);
248 if (old_expire !=
NULL)
249 *old_expire =
m0_time(ots.it_value.tv_sec,
250 ots.it_value.tv_nsec);
255 void (*sighandler)(
int, siginfo_t*,
void*))
260 sigemptyset(&sa.sa_mask);
261 if (sighandler ==
NULL) {
262 sa.sa_handler = SIG_DFL;
264 sa.sa_sigaction = sighandler;
265 sa.sa_flags = SA_SIGINFO;
268 return sigaction(signo, &sa,
NULL) == 0 ? 0 : errno;
283 timer =
si->si_value.sival_ptr;
485 #undef M0_TRACE_SUBSYSTEM M0_INTERNAL void m0_timer_locality_fini(struct m0_timer_locality *loc)
static struct m0_timer_tid * locality_tid_find(struct m0_timer_locality *loc, pid_t tid)
M0_INTERNAL int m0_timer_thread_attach(struct m0_timer_locality *loc)
static int timer_hard_init(struct m0_timer *timer, struct m0_timer_locality *loc)
int(* tmr_init)(struct m0_timer *timer, struct m0_timer_locality *loc)
static void timer_working_thread(struct m0_timer *timer)
m0_time_t m0_time_monotonic_offset
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
int m0_thread_join(struct m0_thread *q)
M0_TL_DEFINE(tid, static, struct m0_timer_tid)
const m0_time_t M0_TIME_NEVER
M0_INTERNAL bool m0_semaphore_timeddown(struct m0_semaphore *semaphore, const m0_time_t abs_timeout)
uint64_t m0_time_nanoseconds(const m0_time_t time)
M0_INTERNAL int m0_timers_init(void)
enum CLOCK_SOURCES M0_CLOCK_SOURCE
static int timer_sigaction(int signo, void(*sighandler)(int, siginfo_t *, void *))
M0_INTERNAL void m0_timer_thread_detach(struct m0_timer_locality *loc)
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
struct m0_semaphore t_sleep_sem
static void timer_hard_fini(struct m0_timer *timer)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
m0_time_t m0_time(uint64_t secs, long ns)
M0_INTERNAL void m0_timers_fini(void)
#define M0_ASSERT_EX(cond)
static void timer_posix_fini(timer_t posix_timer)
static void timer_sighandler(int signo, siginfo_t *si, void *u_ctx)
static void timer_soft_start(struct m0_timer *timer)
void m0_thread_fini(struct m0_thread *q)
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
M0_TL_DESCR_DEFINE(tid, "thread IDs", static, struct m0_timer_tid, tt_linkage, tt_magic, 0x696c444954726d74, 0x686c444954726d74)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
struct m0_timer_tid * tlo_rrtid
uint64_t m0_time_seconds(const m0_time_t time)
static int timer_soft_initfini(struct m0_timer *timer, bool init)
int init(struct workload *w)
static int timer_soft_init(struct m0_timer *timer, struct m0_timer_locality *loc)
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
static void timer_hard_start(struct m0_timer *timer)
int fini(struct workload *w)
static void timer_soft_fini(struct m0_timer *timer)
#define M0_MKTIME(secs, ns)
#define M0_ASSERT_INFO(cond, fmt,...)
static void timer_soft_stop(struct m0_timer *timer)
M0_INTERNAL void m0_timer_locality_init(struct m0_timer_locality *loc)
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
static int clock_source_timer
struct m0_thread t_thread
M0_INTERNAL const struct m0_timer_operations m0_timer_ops[]
static int timer_posix_init(struct m0_timer *timer)
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
static void timer_hard_stop(struct m0_timer *timer)
static m0_time_t timer_time_to_realtime(m0_time_t expire)
static void timer_posix_set(struct m0_timer *timer, m0_time_t expire, m0_time_t *old_expire)
#define m0_tl_for(name, head, obj)
static const m0_time_t zero_time
static struct sync_interactions si
M0_INTERNAL void m0_timer_callback_execute(struct m0_timer *timer)
struct m0_semaphore t_cb_sync_sem
static pid_t timer_locality_tid_next(struct m0_timer_locality *loc)
#define M0_IMPOSSIBLE(fmt,...)