mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 15:03:33 +08:00
Platform cleanup - remove duplicate files
The POSIX and QURT platforms contain several duplicate files. These files have been factored out into platforms/posix/work_queue. The config files have been updated to include the platforms/posix/work_queue module. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -32,27 +32,13 @@
|
||||
############################################################################
|
||||
|
||||
#
|
||||
# NuttX / uORB adapter library
|
||||
# POSIX platform dependent files
|
||||
#
|
||||
|
||||
SRCS = \
|
||||
px4_posix_impl.cpp \
|
||||
px4_posix_tasks.cpp \
|
||||
hrt_thread.c \
|
||||
hrt_queue.c \
|
||||
hrt_work_cancel.c \
|
||||
work_thread.c \
|
||||
work_lock.c \
|
||||
work_queue.c \
|
||||
work_cancel.c \
|
||||
lib_crc32.c \
|
||||
drv_hrt.c \
|
||||
queue.c \
|
||||
dq_addlast.c \
|
||||
dq_remfirst.c \
|
||||
sq_addlast.c \
|
||||
sq_remfirst.c \
|
||||
sq_addafter.c \
|
||||
dq_rem.c
|
||||
|
||||
MAXOPTIMIZATION = -Os
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//#pragma once
|
||||
#include <semaphore.h>
|
||||
#include <stdio.h>
|
||||
#include "work_lock.h"
|
||||
|
||||
|
||||
extern sem_t _work_lock[];
|
||||
|
||||
void work_lock(int id)
|
||||
{
|
||||
//printf("work_lock %d\n", id);
|
||||
sem_wait(&_work_lock[id]);
|
||||
}
|
||||
|
||||
void work_unlock(int id)
|
||||
{
|
||||
//printf("work_unlock %d\n", id);
|
||||
sem_post(&_work_lock[id]);
|
||||
}
|
||||
@@ -121,7 +121,11 @@ int hrt_work_queue(struct work_s *work, worker_t worker, void *arg, uint32_t del
|
||||
//PX4_INFO("hrt work_queue adding work delay=%u time=%lu", delay, work->qtime);
|
||||
|
||||
dq_addlast((dq_entry_t *)work, &wqueue->q);
|
||||
#ifdef __PX4_QURT
|
||||
px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */
|
||||
#else
|
||||
px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */
|
||||
#endif
|
||||
|
||||
hrt_work_unlock();
|
||||
return PX4_OK;
|
||||
@@ -0,0 +1,54 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2014 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
#
|
||||
# POSIX compatible queue and work_queue implementation
|
||||
#
|
||||
|
||||
SRCS = \
|
||||
hrt_thread.c \
|
||||
hrt_queue.c \
|
||||
hrt_work_cancel.c \
|
||||
work_thread.c \
|
||||
work_lock.c \
|
||||
work_queue.c \
|
||||
work_cancel.c \
|
||||
queue.c \
|
||||
dq_addlast.c \
|
||||
dq_remfirst.c \
|
||||
sq_addlast.c \
|
||||
sq_remfirst.c \
|
||||
sq_addafter.c \
|
||||
dq_rem.c
|
||||
|
||||
MAXOPTIMIZATION = -Os
|
||||
@@ -0,0 +1,51 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2015 Mark Charlebois. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <px4_log.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdio.h>
|
||||
#include "work_lock.h"
|
||||
|
||||
|
||||
extern sem_t _work_lock[];
|
||||
|
||||
void work_lock(int id)
|
||||
{
|
||||
//PX4_INFO("work_lock %d", id);
|
||||
sem_wait(&_work_lock[id]);
|
||||
}
|
||||
|
||||
void work_unlock(int id)
|
||||
{
|
||||
//PX4_INFO("work_unlock %d", id);
|
||||
sem_post(&_work_lock[id]);
|
||||
}
|
||||
+4
@@ -124,7 +124,11 @@ int work_queue(int qid, struct work_s *work, worker_t worker, void *arg, uint32_
|
||||
work->qtime = clock_systimer(); /* Time work queued */
|
||||
|
||||
dq_addlast((dq_entry_t *)work, &wqueue->q);
|
||||
#ifdef __PX4_QURT
|
||||
px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */
|
||||
#else
|
||||
px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */
|
||||
#endif
|
||||
|
||||
work_unlock(qid);
|
||||
return PX4_OK;
|
||||
+4
-4
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
#include <px4_time.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -114,7 +115,7 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
|
||||
*/
|
||||
|
||||
elapsed = USEC2TICK(clock_systimer() - work->qtime);
|
||||
//PX4_INFO("work_process: queue=%p in ticks elapsed=%lu delay=%u time=%u", wqueue, elapsed, work->delay,clock_systimer());
|
||||
//printf("work_process: in ticks elapsed=%lu delay=%u\n", elapsed, work->delay);
|
||||
if (elapsed >= work->delay)
|
||||
{
|
||||
/* Remove the ready-to-execute work from the list */
|
||||
@@ -138,11 +139,10 @@ static void work_process(FAR struct wqueue_s *wqueue, int lock_id)
|
||||
|
||||
work_unlock(lock_id);
|
||||
if (!worker) {
|
||||
PX4_ERR("MESSED UP: worker = 0");
|
||||
PX4_WARN("MESSED UP: worker = 0\n");
|
||||
}
|
||||
else {
|
||||
else
|
||||
worker(arg);
|
||||
}
|
||||
|
||||
/* Now, unfortunately, since we re-enabled interrupts we don't
|
||||
* know the state of the work list and we will have to start
|
||||
Reference in New Issue
Block a user