Commit Graph

122 Commits

Author SHA1 Message Date
Peter Barker 4ebde78bbf AP_HAL_Linux: throw warning if we ever stop-clock backwards
Also don't compile in the stop_clock symbol to make it clear changes in
this method won't affect vehicles
2020-09-15 10:02:36 +10:00
Patrick José Pereira 248daa85a1 AP_HAL_Linux: Scheduler: Use pthread_* over sched_* calls for setschedparam
musl implements `sched_*` following the posix standard,
where `sched_setschedule` is used for process scheduling.
Linux implementation defines `sched_*` functions based in
the thread scheduler and not with the process.

Using `pthread_*` should be used to follow such standard.

Ref: https://pubs.opengroup.org/onlinepubs/9699919799/

From: https://www.openwall.com/lists/musl/2016/03/01/5

> ... Linux does not provide a way
> to set scheduling parameters for a _process_, only for threads. The
> sched_setscheduler syscall is documented as taking a pid but actually
> takes a thread id and only operates on that thread. glibc just ignores
> this and provides sched_* functions that do the wrong thing.

This can be fixed by using `pthread_setschedparam` and requesting the current
thread id via `pthread_self`.

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-08-25 07:15:00 -07:00
Andrew Tridgell 67bd4ed396 AP_HAL_Linux: use take_blocking instead of HAL_SEMAPHORE_BLOCK_FOREVER
this makes for cleaner and smaller code as the failure case is not
needed
2020-01-19 20:19:30 +11:00
Andrew Tridgell 019f441b2f HAL_Linux: added uartH 2019-07-12 17:01:21 +10:00
Aaron Wang Shi 8350943e78 AP_HAL_Linux: reduce RCInput_RPI CPU consumption to 1/4 2019-01-24 19:12:21 -08:00
Michael du Breuil f506a96b7f AP_HAL_Linux: Handle scripting priority 2018-10-09 10:08:52 +11:00
Lucas De Marchi 0990fc4400 AP_HAL_Linux: send warning to stderr 2018-09-19 23:21:13 -07:00
Peter Barker 220a3d19bf AP_HAL_Linux: do not attempt to run examples realtime unless root 2018-09-19 22:40:20 -07:00
Peter Barker 43c07259f3 AP_HAL_Linux: break out init_realtime 2018-09-19 22:40:20 -07:00
Francisco Ferreira 5b383bae16
AP_HAL_Linux: force Thread stack to have minimum size
Check that Thread stack size is the minimum allowed

Also add 256k to HAL-independent request stack size
2018-09-06 19:07:13 +01:00
Lucas De Marchi 5068f2e8fd AP_HAL_Linux: fix log after tonealarm thread removal
../../libraries/AP_HAL_Linux/Scheduler.cpp: In member function ‘void Linux::Scheduler::_debug_stack()’:
../../libraries/AP_HAL_Linux/Scheduler.cpp:127:47: warning: format ‘%zu’ expects a matching ‘size_t’ argument [-Wformat=]
                 _uart_thread.get_stack_usage());
                                               ^
2018-08-12 20:29:35 -07:00
Francisco Ferreira 1d7f3e48a4
AP_HAL_Linux: remove CAN thread management
Also fix comment
2018-08-12 13:35:01 +01:00
Jonathan Challinger ddf0333a24 AP_HAL_Linux: reflect changes to tonealarm interface 2018-07-30 14:02:12 +10:00
Lucas De Marchi d2446e1219 AP_HAL_Linux: use Thread abstraction to create thread
The open coded version has the same problem fixed by Thread abstraction:
the order of the calls matters and it's easy to call in the wrong order.
Here pthread_attr_setschedparam() and pthread_attr_setschedpolicy()
should be swapped, like in 62c2f737d5 (AP_HAL_Linux: fix setting RT priorities.)
2018-07-11 10:00:29 +10:00
Andrew Tridgell 492978c0fa HAL_Linux: removed restriction on delay in threads
threads other than the main thread should be able to sleep, but not
call the delay callback
2018-07-09 19:41:18 +10:00
Andrew Tridgell 9918ae3209 HAL_Linux: implement thread_create() 2018-07-09 19:41:18 +10:00
Andrew Tridgell 9ae6734469 HAL_Linux: support uartG 2018-06-29 08:17:38 +10:00
Michael du Breuil 80d1a1de9a AP_HAL_Linux: Remove timer process suspension interface 2018-06-06 07:16:58 +10:00
Francisco Ferreira 5e821428a1 AP_HAL_Linux: remove Qualcomm board support 2018-05-17 09:57:20 +10:00
Peter Barker d5cad015dc AP_HAL_Linux: move delay callback handling to base HAL Scheduler class 2018-05-09 16:15:38 +10:00
Andrew Tridgell 26161ee467 HAL_Linux: Storage::_timer_tick is an override 2018-02-07 20:33:45 +11:00
Andrew Tridgell 22de99dd58 HAL_Linux: implement _timer_tick in UARTDriver 2018-02-07 20:33:45 +11:00
Nikita Tomilov 43bfcbc8e2 AP_HAL_Linux: CAN: Rename CANDriver -> CANManager 2018-01-17 07:24:17 -08:00
Nikita Tomilov d0fc481202 AP_HAL_Linux: CAN: Rename Linux::LinuxCAN -> Linux::CAN 2018-01-17 07:24:17 -08:00
Alexey Bulatov e0acbd3e53 AP_HAL_LINUX: Add CAN to timer_task 2018-01-17 07:24:17 -08:00
Peter Barker 044cac42e8 AP_HAL_Linux: make in_main_thread const and override 2017-09-19 09:40:11 +10:00
Lucas De Marchi 7ba82ff23a AP_HAL_Linux: remove raspilot
It's not being sold, there are just a few (different) engineering
samples built and there are no plans for this to go forward for people
that were pushing it.
2017-09-12 15:06:19 -07:00
Francisco Ferreira 4398be2275 AP_HAL_Linux: remove URUS 2017-09-11 10:04:11 -07:00
Lucas De Marchi 5ea1784838 global: remove AP_HAL::in_timerprocess()
This is not used and in the only places it would make sense would be
internally to the scheduler so remove it.
2017-08-03 20:25:14 -07:00
Lucas De Marchi 93a558ce5c AP_HAL_Linux: do not call delay callbacks on other threads
If a thread other than the main one calls Scheduler::delay() we could
end up triggering the call of delay callbacks. Those should only ever
happen on the main thread.
2017-08-03 20:24:57 -07:00
Lucas De Marchi c170c2a847 AP_HAL_Linux: remove register_timer_process with extra arg
This is not used anymore.
2017-08-02 08:00:53 -07:00
Lucas De Marchi 0a158f6d3f AP_HAL_Linux: remove support for timesliced timer
This has long been replaced by the bus per thread scheme.
2017-08-02 08:00:53 -07:00
Lucas De Marchi e803045d1f AP_HAL_Linux: Scheduler: increase stack for scheduler threads
RPI-based boards that use RCInput_RPI need more stack space otherwise we
end up with stack corruption. This leads to crash particularly when also
using GPIO_RPI since it may change what that driver is poking on memory.

This increases stack size to 1M which is overkill for most of other
boards with a more controllable stack usage. However this exposes that
on multiple different HWs a single point for stack size decision may not
be the best.  This can be improved in future.
2017-05-23 09:09:51 +10:00
Peter Barker c78f3b9e78 AP_HAL_Linux: use HAL_SEMAPHORE_BLOCK_FOREVER macro 2017-05-08 10:23:03 +09:00
Ivan Smirnov d4d35bdcbd AP_HAL_Linux: Scheduler: added _timer_tick for uartD 2016-12-07 10:25:00 -08:00
Peter Barker cf5ed25c9e AP_HAL_Linux: do not attempt realtime when compiling Replay 2016-11-16 22:25:18 -02:00
Ralf Ramsauer 530d3230df Linux: Scheduler: don't ignore return values
Several return values in the constructor of the scheduler were ignored
before, while they should be respected.

I found that bug while strac'ing ardupilot as it failed at some later
point.

Signed-off-by: Ralf Ramsauer <ralf.ramsauer@othr.de>
2016-11-03 17:27:37 -03:00
Lucas De Marchi 2b5f9fdd6b AP_HAL_Linux: teardown scheduler threads 2016-11-02 16:28:20 -02:00
murata c808ee2f49 Global: To nullptr from NULL.
RC_Channel: To nullptr from NULL.

AC_Fence: To nullptr from NULL.

AC_Avoidance: To nullptr from NULL.

AC_PrecLand: To nullptr from NULL.

DataFlash: To nullptr from NULL.

SITL: To nullptr from NULL.

GCS_MAVLink: To nullptr from NULL.

DataFlash: To nullptr from NULL.

AP_Compass: To nullptr from NULL.

Global: To nullptr from NULL.

Global: To nullptr from NULL.
2016-11-02 16:04:47 -02:00
hiro2233 37877f1530 AP_HAL_Linux: Added URUS macro to Scheduler 2016-10-27 11:51:32 -02:00
Martin Evans 6f6112d7c2 AP_HAL_Linux: Add setting for GPIO for Dark board
Just like other RPI-based boards.
2016-10-24 10:00:24 -02:00
Lucas De Marchi 833f565f09 AP_HAL_Linux: prefix threads with ap
This makes it consistent with bus threads and easier to grep from a `ps`
call.
2016-08-29 10:27:36 -03:00
Andrew Tridgell aaaa6d38c7 HAL_Linux: initial support for Disco 2016-07-20 13:35:51 +10:00
Lucas De Marchi 37f6b51746 AP_HAL_Linux: Scheduler: set stack sizes to 256k
Running the vehicles we check the stack size doesn't grow too much by
enabling the DEBUG_STACK in the scheduler. Even on 64bit boards the
stack is consistent around 4k. Just to be a little conservative, let it
be a little bit more that that: 256kB.

Since we have RT prio and we call mlock(), the memory for the stack of
each thread is locked in memory. This means we are effectively taking
that much memory. The default stack size varies per distro, but it's
common to have 8MB for 64 bit boards and 4MB for 32 bit boards. Here is
the output of ps -L -o 'comm,rtprio,rss $(pidof arducopter-quad)', showing the
RSS of arducopter-quad before and after this change:

Before:
	COMMAND         RTPRIO   RSS
	arducopter-quad     12 46960
	sched-timer         15 46960
	sched-uart          14 46960
	sched-rcin          13 46960
	sched-tonealarm     11 46960
	sched-io            10 46960

After:
	COMMAND         RTPRIO   RSS
	arducopter-quad     12  7320
	sched-timer         15  7320
	sched-uart          14  7320
	sched-rcin          13  7320
	sched-tonealarm     11  7320
	sched-io            10  7320
2016-05-12 13:35:23 -03:00
Lucas De Marchi d970451331 AP_HAL_Linux: Scheduler: debug stack usage 2016-05-12 13:35:23 -03:00
Andrew Tridgell c7dabad02c HAL_Linux: added uartF 2016-04-20 09:39:49 +10:00
Lucas De Marchi 0ad436c337 AP_HAL_Linux: Scheduler: bring back scheduler table
Use a scheduler table to list threads' properties in a single place.
2016-02-12 23:42:34 -02:00
Lucas De Marchi a1b62b4984 AP_HAL_Linux: Scheduler: use PeriodicThread
Some tasks were not accounting for the time to execute the tasks. Now
that we are using the infra from PeriodicThread all of them are.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 860d5aaf84 AP_HAL_Linux: Scheduler: move rpcmem initialization to setup phase
This was the only piece remaining in the timer thread that was used only
to setup the thread.
2016-02-12 23:42:34 -02:00
Lucas De Marchi e3beef0f77 AP_HAL_Linux: Scheduler: remove unused parameter 2016-02-12 23:42:34 -02:00