mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Work queues: Move to POSIX semaphore abstraction
This commit is contained in:
parent
604644d823
commit
d73deabf5c
@ -32,6 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <px4_log.h>
|
||||
#include <px4_posix.h>
|
||||
#include <semaphore.h>
|
||||
#include <px4_workqueue.h>
|
||||
|
||||
@ -39,7 +40,7 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern sem_t _hrt_work_lock;
|
||||
extern px4_sem_t _hrt_work_lock;
|
||||
extern struct wqueue_s g_hrt_work;
|
||||
|
||||
void hrt_work_queue_init(void);
|
||||
@ -49,15 +50,13 @@ void hrt_work_cancel(struct work_s *work);
|
||||
static inline void hrt_work_lock(void);
|
||||
static inline void hrt_work_lock()
|
||||
{
|
||||
//PX4_INFO("hrt_work_lock");
|
||||
sem_wait(&_hrt_work_lock);
|
||||
px4_sem_wait(&_hrt_work_lock);
|
||||
}
|
||||
|
||||
static inline void hrt_work_unlock(void);
|
||||
static inline void hrt_work_unlock()
|
||||
{
|
||||
//PX4_INFO("hrt_work_unlock");
|
||||
sem_post(&_hrt_work_lock);
|
||||
px4_sem_post(&_hrt_work_lock);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@ -66,7 +66,7 @@ struct wqueue_s g_hrt_work;
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
sem_t _hrt_work_lock;
|
||||
px4_sem_t _hrt_work_lock;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -241,7 +241,7 @@ static int work_hrtthread(int argc, char *argv[])
|
||||
|
||||
void hrt_work_queue_init(void)
|
||||
{
|
||||
sem_init(&_hrt_work_lock, 0, 1);
|
||||
px4_sem_init(&_hrt_work_lock, 0, 1);
|
||||
|
||||
// Create high priority worker thread
|
||||
g_hrt_work.pid = px4_task_spawn_cmd("wkr_hrt",
|
||||
|
||||
@ -31,21 +31,19 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <px4_log.h>
|
||||
#include <semaphore.h>
|
||||
#include <px4_posix.h>
|
||||
#include <stdio.h>
|
||||
#include "work_lock.h"
|
||||
|
||||
|
||||
extern sem_t _work_lock[];
|
||||
extern px4_sem_t _work_lock[];
|
||||
|
||||
void work_lock(int id)
|
||||
{
|
||||
//PX4_INFO("work_lock %d", id);
|
||||
sem_wait(&_work_lock[id]);
|
||||
px4_sem_wait(&_work_lock[id]);
|
||||
}
|
||||
|
||||
void work_unlock(int id)
|
||||
{
|
||||
//PX4_INFO("work_unlock %d", id);
|
||||
sem_post(&_work_lock[id]);
|
||||
px4_sem_post(&_work_lock[id]);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ struct wqueue_s g_work[NWORKERS];
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
****************************************************************************/
|
||||
sem_t _work_lock[NWORKERS];
|
||||
px4_sem_t _work_lock[NWORKERS];
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -187,10 +187,10 @@ static void work_process(struct wqueue_s *wqueue, int lock_id)
|
||||
****************************************************************************/
|
||||
void work_queues_init(void)
|
||||
{
|
||||
sem_init(&_work_lock[HPWORK], 0, 1);
|
||||
sem_init(&_work_lock[LPWORK], 0, 1);
|
||||
px4_sem_init(&_work_lock[HPWORK], 0, 1);
|
||||
px4_sem_init(&_work_lock[LPWORK], 0, 1);
|
||||
#ifdef CONFIG_SCHED_USRWORK
|
||||
sem_init(&_work_lock[USRWORK], 0, 1);
|
||||
px4_sem_init(&_work_lock[USRWORK], 0, 1);
|
||||
#endif
|
||||
|
||||
// Create high priority worker thread
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user