Commit Graph

61 Commits

Author SHA1 Message Date
Peter Barker eb73a14da8 AP_HAL_Linux: add missing override keywords 2019-02-22 15:01:09 +00:00
Peter Barker 43c07259f3 AP_HAL_Linux: break out init_realtime 2018-09-19 22:40:20 -07: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 9918ae3209 HAL_Linux: implement thread_create() 2018-07-09 19:41:18 +10:00
Michael du Breuil 80d1a1de9a AP_HAL_Linux: Remove timer process suspension interface 2018-06-06 07:16:58 +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
Peter Barker 044cac42e8 AP_HAL_Linux: make in_main_thread const and override 2017-09-19 09:40:11 +10: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 2b5f9fdd6b AP_HAL_Linux: teardown scheduler threads 2016-11-02 16:28:20 -02:00
Lucas De Marchi 590539f674 AP_HAL_Linux: implement threaded I2C 2016-07-30 00:55:27 -03:00
Lucas De Marchi f36e8d9c05 AP_HAL_Linux: remove AP_HAL_Linux_Namespace header
This centralized namespace header encourages centralizing things on
umbrella headers that are a pain to maintain. Force each part of
AP_HAL_Linux to include what is used.

While at it, do some whitespace cleanups and minor changes to adhere to
coding style.
2016-07-29 20:25:03 -03:00
Lucas De Marchi d970451331 AP_HAL_Linux: Scheduler: debug stack usage 2016-05-12 13:35:23 -03:00
Lucas De Marchi 7debd14683 AP_HAL_Linux: Scheduler: remove unused _in_io_proc 2016-02-12 23:42:34 -02:00
Lucas De Marchi fbb3bb2fd0 AP_HAL_Linux: Scheduler: remove unused _timer_event_missed 2016-02-12 23:42:34 -02:00
Lucas De Marchi f39a6745d1 Global: remove unused _timer_pending from scheduler 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 e3beef0f77 AP_HAL_Linux: Scheduler: remove unused parameter 2016-02-12 23:42:34 -02:00
Lucas De Marchi 2b61eaf9f2 Global: remove {begin,end}_atomic from scheduler
These are never used and largely not implemented.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 9aa49cda93 Global: remove system_initializing() from scheduler
This is not used anymore.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 9cf9fc152b AP_HAL_Linux: use pthread's barrier instead of polling
Use pthread's barrier so we don't keep waking up threads with possibly
higher priority during initialization phase.

This also synchronizes all of them to a single point. With the previous
approach it was possible (but unlikely) that a thread hadn't reach the
synchronization point when main thread signalize "system initialized".
2016-02-12 23:42:34 -02:00
Lucas De Marchi 2b0e214168 AP_HAL_Linux: Scheduler: move synchronization to common method 2016-02-12 23:42:34 -02:00
Lucas De Marchi a183ff8d32 AP_HAL_Linux: Scheduler: use Thread abstraction 2016-02-12 23:42:34 -02:00
Lucas De Marchi 5e9b45ebc2 AP_HAL_Linux: Scheduler: make microsleep() public
This will be used outside of scheduler class.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 27999b339d AP_HAL_Linux: Scheduler: include cleanups
While at it also remove some wrong whitespaces.
2016-02-08 13:28:31 -02:00
Julien BERAUD 4acc121bd6 AP_HAL_Linux: support for timesliced timers
In order for lower frequency timers not to be called at the same iteration
of the main timer loop. This improves scheduling.
2016-01-18 16:57:48 -02:00
Andrew Tridgell dc8a3bbf92 HAL_Linux: added qflight board subtype 2015-12-27 16:12:27 +11:00
Lucas De Marchi 2439826c19 AP_HAL_Linux: use init() method without arguments
Override the init() method from parent class that doesn't have a
parameter since it's not used here.
2015-12-02 14:49:11 -02:00
Caio Marcelo de Oliveira Filho e0a6d83457 AP_HAL_LINUX: remove unused functions 2015-11-20 12:36:25 +09:00
Caio Marcelo de Oliveira Filho ff016c4b5a AP_HAL_Linux: implement new AP_HAL functions
Implement the new AP_HAL functions and use them in the Scheduler when
possible.

The '_sketch_start_time' was renamed and moved as a detail of
implementation of the functions code. It allows the code to return time
starting from zero.

The 'stopped_clock_usec' was renamed to follow convention in the file
and add a getter so that AP_HAL functions can reach it. It's not a
problem this getter is public because in practice, regular code
shouldn't even access the Linux::Scheduler directly -- only code that
should is from Linux implementation.
2015-11-20 12:25:39 +09:00
Lucas De Marchi 1b07dabeb7 Replace prog_char and prog_char_t with char
prog_char and prog_char_t are now the same as char on supported
platforms. So, just change all places that use them and prefer char
instead.

AVR-specific places were not changed.
2015-10-30 14:35:30 +09:00
Lucas De Marchi 9eaf7c5660 AP_HAL: add format attribute to panic() 2015-10-24 14:26:36 +11:00
Lucas De Marchi ad61a93c14 AP_HAL: turn panic() into a variadic method
Change the declaration on all HAL implementations so panic() in future
may implement a printf-like interface.
2015-10-24 14:26:35 +11:00
Lucas De Marchi 2ac96b942c AP_HAL_Linux: remove prefix from AP_HAL_Linux classes
We have already a Linux namespace, so there's no need to prefix Linux on
all names.
2015-10-21 10:11:19 +11:00
Gustavo Jose de Sousa 124b750c10 AP_HAL_Linux: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:28:43 +10:00
Andrew Tridgell c44ab01be8 AP_HAL: use noreturn attribute on panic
should reduce coverity warnings
2015-06-08 21:09:08 +10:00
Lucas De Marchi 2c48434110 AP_HAL_Linux: use a table to initialize threads
Refactor function calls into a table and pass in the name so it can be
used in error message.
2015-04-14 09:17:21 +10:00
Lucas De Marchi e3d78b8960 AP_HAL_Linux: fix passing callback to member function
It's undefined behavior to pass the callback to pthread to a class
member like we were doing. Refactor the code so the callbacks are static
members.

This fixes the following warnings:

libraries/AP_HAL_Linux/Scheduler.cpp: In member function 'virtual void Linux::LinuxScheduler::init(void*)':
/home/lucas/p/dronecode/ardupilot/libraries/AP_HAL_Linux/Scheduler.cpp:61:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_timer_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:65:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_uart_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:69:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_rcin_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:73:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_tonealarm_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:77:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_io_thread);
2015-04-14 09:17:20 +10:00
Lucas De Marchi 62c2f737d5 AP_HAL_Linux: fix setting RT priorities
LinuxScheduler::init() was not really working as it should. This was the
result of "ps -Leo class,rtprio,wchan,comm | grep ArduCopter":

FF      12 futex_ ArduCopter.elf
FF      12 usleep ArduCopter.elf
FF      12 hrtime ArduCopter.elf
FF      12 poll_s ArduCopter.elf
FF      12 hrtime ArduCopter.elf
FF      12 hrtime ArduCopter.elf

As can be seen all the threads run with the same priority, the one of the main
thread. There were basically 2 mistakes:

	1) pthread_attr_setschedpolicy() needs to be called before
	   pthread_attr_setschedparam(). Otherwise the latter will just return
	   an error and not set the priority

	2) pthread_create() defaults to ignore the priority and inherit the
	   it from the parent thread. pthread_attr_setinheritsched() needs to
	   be called to change the behavior to PTHREAD_EXPLICIT_SCHED. See
	   pthread_attr_setinheritsched(3) for an example program to test the
	   behaviors.

Also, it's undefined behavior to call pthread_attr_init() several times on the
same pthread_attr_t. Although we could reutilize the same attribute without
calling  pthread_attr_init() again, lets refactor the code a little bit, so all
the pthread calls are in a single place. Then also call pthread_attr_destroy()
when we are done.
2015-04-14 09:17:20 +10:00
Staroselskii Georgii 64da7f0360 AP_HAL_Linux: fix macro that defines number of I/O callbacks 2015-02-12 12:52:56 +11:00
Andrew Tridgell 193bda068c HAL_Linux: run IO processes when we do a stop_clock()
this has the effect of allowing logging to progress in Replay where we
are running at much more than realtime speeds
2014-12-08 11:24:39 +11:00
bugobliterator 298b27444a HAL_Linux: Add ToneAlarm Driver to Linux_HAL
ToneAlarm is setup for Beaglebone Black using pwm, toneAlarm thread runs on second last priority.
2014-11-10 06:27:48 +11:00
Andrew Tridgell 024d3b71e7 HAL_Linux: use a semaphore in suspend_timer_procs()
this is the start of multi-core aware code
2014-08-22 21:13:11 +10:00
Andrew Tridgell ead82ee581 HAL_Linux: implement millis64() and micros64() 2014-08-20 08:00:21 +10:00
bugobliterator ac11d282b5 HAL_Linux: Add support for PPM input to HAL_Linux
rcin thread continuously scans for values inside ring buffer maintained by pru with rcinpru0 firmware.
2014-08-19 10:08:16 +10:00
Andrew Tridgell fc8068adfe HAL_Linux: use board subtypes 2014-07-14 09:44:35 +10:00
Andrew Tridgell 74ee70d463 HAL_Linux: updates for ERLE board type 2014-07-14 08:52:27 +10:00