POSIX: fixed hrt call and workqueue implementation

The HRT call processing normally happens via HW timer interrupt
handler. Since the POSIX port has no ISR handling, the HP work
queue is used.

Instead of irq_save() and irq_restore() calls to disable/enable
interrupts, a mutex is used to protect each queue.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-05 00:27:14 -07:00
parent 12a25e4b63
commit e24405d374
9 changed files with 144 additions and 41 deletions
@@ -46,9 +46,17 @@
px4::AppState HRTTest::appState;
static struct hrt_call t1;
static int update_interval = 1;
static void timer_expired(void *arg)
{
static int i = 0;
printf("Test\n");
if (i < 5) {
i++;
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
}
}
int HRTTest::main()
@@ -67,18 +75,15 @@ int HRTTest::main()
printf("Elapsed time %llu in 1 sec (sleep)\n", (unsigned long long)elt);
printf("Start time %llu\n", (unsigned long long)t);
struct hrt_call t1;
int update_interval = 1;
memset(&t1, 0, sizeof(t1));
printf("HRT_CALL %d\n", hrt_called(&t1));
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
sleep(2);
printf("HRT_CALL %d\n", hrt_called(&t1));
printf("HRT_CALL - %d\n", hrt_called(&t1));
hrt_cancel(&t1);
printf("HRT_CALL %d\n", hrt_called(&t1));
printf("HRT_CALL + %d\n", hrt_called(&t1));
return 0;
}
@@ -32,7 +32,7 @@
****************************************************************************/
/**
* @file hello_main.cpp
* @file hrt_test_main.cpp
* Example for Linux
*
* @author Mark Charlebois <charlebm@gmail.com>
@@ -44,9 +44,9 @@
int PX4_MAIN(int argc, char **argv)
{
px4::init(argc, argv, "hello");
px4::init(argc, argv, "hrt_test");
printf("hello\n");
printf("starting\n");
HRTTest test;
test.main();