| 1 | /* |
| 2 | * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca> |
| 3 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | * Copyright (C) 2012 David Goulet <dgoulet@efficios.com> |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0-only |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef CONSUMER_TIMER_H |
| 11 | #define CONSUMER_TIMER_H |
| 12 | |
| 13 | #include <pthread.h> |
| 14 | |
| 15 | #include "consumer.h" |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | #define LTTNG_CONSUMER_SIG_SWITCH SIGRTMIN + 10 |
| 22 | #define LTTNG_CONSUMER_SIG_TEARDOWN SIGRTMIN + 11 |
| 23 | #define LTTNG_CONSUMER_SIG_LIVE SIGRTMIN + 12 |
| 24 | #define LTTNG_CONSUMER_SIG_MONITOR SIGRTMIN + 13 |
| 25 | #define LTTNG_CONSUMER_SIG_EXIT SIGRTMIN + 14 |
| 26 | |
| 27 | #define CLOCKID CLOCK_MONOTONIC |
| 28 | |
| 29 | /* |
| 30 | * Handle timer teardown race wrt memory free of private data by consumer |
| 31 | * signals are handled by a single thread, which permits a synchronization |
| 32 | * point between handling of each signal. Internal lock ensures mutual |
| 33 | * exclusion. |
| 34 | */ |
| 35 | struct timer_signal_data { |
| 36 | pthread_t tid; /* thread id managing signals */ |
| 37 | int setup_done; |
| 38 | int qs_done; |
| 39 | pthread_mutex_t lock; |
| 40 | }; |
| 41 | |
| 42 | void consumer_timer_switch_start(struct lttng_consumer_channel *channel, |
| 43 | unsigned int switch_timer_interval_us); |
| 44 | void consumer_timer_switch_stop(struct lttng_consumer_channel *channel); |
| 45 | void consumer_timer_live_start(struct lttng_consumer_channel *channel, |
| 46 | unsigned int live_timer_interval_us); |
| 47 | void consumer_timer_live_stop(struct lttng_consumer_channel *channel); |
| 48 | int consumer_timer_monitor_start(struct lttng_consumer_channel *channel, |
| 49 | unsigned int monitor_timer_interval_us); |
| 50 | int consumer_timer_monitor_stop(struct lttng_consumer_channel *channel); |
| 51 | void *consumer_timer_thread(void *data); |
| 52 | int consumer_signal_init(void); |
| 53 | |
| 54 | int consumer_flush_kernel_index(struct lttng_consumer_stream *stream); |
| 55 | int consumer_flush_ust_index(struct lttng_consumer_stream *stream); |
| 56 | |
| 57 | int consumer_timer_thread_get_channel_monitor_pipe(void); |
| 58 | int consumer_timer_thread_set_channel_monitor_pipe(int fd); |
| 59 | |
| 60 | #ifdef __cplusplus |
| 61 | } |
| 62 | #endif |
| 63 | |
| 64 | #endif /* CONSUMER_TIMER_H */ |