QuRT: Added HRT workqueues as per POSIX

A high rate workqueue is required that acts like an interrupt handler
for a HW timer.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois 2015-06-11 18:13:36 -07:00
parent 83bcb95999
commit e4a8f32f1b
5 changed files with 20 additions and 5 deletions

View File

@ -7,7 +7,6 @@
#
MODULES += drivers/device
MODULES += drivers/blinkm
MODULES += drivers/buzzer
MODULES += drivers/hil
MODULES += drivers/rgbled
MODULES += drivers/led

View File

@ -57,7 +57,7 @@
#define MAX_CMD_LEN 100
#define PX4_MAX_TASKS 100
#define PX4_MAX_TASKS 50
#define SHELL_TASK_ID (PX4_MAX_TASKS+1)
pthread_t _shell_task_id = 0;

View File

@ -40,6 +40,9 @@ SRCDIR=$(dir $(MODULE_MK))
SRCS = \
px4_qurt_impl.cpp \
px4_qurt_tasks.cpp \
hrt_thread.c \
hrt_queue.c \
hrt_work_cancel.c \
work_thread.c \
work_queue.c \
work_lock.c \

View File

@ -49,8 +49,11 @@
#include <unistd.h>
#include <semaphore.h>
#include "systemlib/param/param.h"
#include "hrt_work.h"
extern pthread_t _shell_task_id;
__BEGIN_DECLS
// FIXME - sysconf(_SC_CLK_TCK) not supported
@ -92,7 +95,10 @@ void init_once(void)
// Required for QuRT
//_posix_init();
_shell_task_id = pthread_self();
PX4_INFO("Shell id is %lu", _shell_task_id);
work_queues_init();
hrt_work_queue_init();
hrt_init();
}

View File

@ -57,7 +57,11 @@
#define MAX_CMD_LEN 100
#define PX4_MAX_TASKS 100
#define PX4_MAX_TASKS 50
#define SHELL_TASK_ID (PX4_MAX_TASKS+1)
pthread_t _shell_task_id = 0;
struct task_entry
{
pthread_t pid;
@ -269,13 +273,16 @@ int px4_getpid()
{
pthread_t pid = pthread_self();
if (pid == _shell_task_id)
return SHELL_TASK_ID;
// Get pthread ID from the opaque ID
for (int i=0; i<PX4_MAX_TASKS; ++i) {
if (taskmap[i].pid == pid) {
if (taskmap[i].isused && taskmap[i].pid == pid) {
return i;
}
}
PX4_ERR("px4_getpid() called from non-thread context!");
PX4_ERR("px4_getpid() called from unknown thread context!");
return -EINVAL;
}