linux: Use Unix signals to notify when a timer is pending

Use Unix signals in software timer implementation.  This makes the
code a little more efficient.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2020-06-07 20:38:20 -04:00
parent ffeafb690b
commit 913d099261
5 changed files with 105 additions and 57 deletions

View File

@@ -2,6 +2,7 @@
#define __LINUX_INTERNAL_H
// Local definitions for micro-controllers running on linux
#include <signal.h> // sigset_t
#include <stdint.h> // uint32_t
#include "autoconf.h" // CONFIG_CLOCK_FREQ
@@ -10,7 +11,6 @@
#define GPIO2PORT(PIN) ((PIN) / MAX_GPIO_LINES)
#define GPIO2PIN(PIN) ((PIN) % MAX_GPIO_LINES)
#define NSECS 1000000000
#define NSECS_PER_TICK (NSECS / CONFIG_CLOCK_FREQ)
@@ -19,10 +19,12 @@ void report_errno(char *where, int rc);
int set_non_blocking(int fd);
int set_close_on_exec(int fd);
int console_setup(char *name);
void console_sleep(struct timespec ts);
void console_sleep(sigset_t *sigset);
// timer.c
int timer_check_periodic(uint32_t *ts);
void timer_disable_signals(void);
void timer_enable_signals(void);
// watchdog.c
int watchdog_setup(void);