From f25947b964f31eb55e8f836077bad59973486eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 19 Sep 2016 20:29:49 +0200 Subject: [PATCH] hrt_work_queue posix: only send a wake-up signal if not called from own thread The simulated timer interrupt always adds a new scheduled work task, which is called from the work queue thread. Sending the signal creates measurable overhead (~5% of the px4 CPU runtime) and is unnecessary, since the thread is not sleeping anyway. --- src/platforms/posix/work_queue/hrt_queue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/platforms/posix/work_queue/hrt_queue.c b/src/platforms/posix/work_queue/hrt_queue.c index 4238f0733e..bc7d89b563 100644 --- a/src/platforms/posix/work_queue/hrt_queue.c +++ b/src/platforms/posix/work_queue/hrt_queue.c @@ -121,11 +121,15 @@ 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); + + if (px4_getpid() != wqueue->pid) { /* only need to wake up if called from a different thread */ #ifdef __PX4_QURT - px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */ + px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */ #else - px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */ + //wqueue->pid == own task? -> don't signal + px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */ #endif + } hrt_work_unlock(); return PX4_OK;