Commit Graph

46 Commits

Author SHA1 Message Date
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
Andrew Tridgell 3fa2207a2d AP_HAL: allow for microsecond resolution in scheduler->stop_clock()
this makes 400Hz in the replay code possible
2014-02-26 19:33:39 +11:00
Andrew Tridgell 117b77460e HAL_Linux: added stop_clock hack! 2014-02-15 05:28:08 +11:00
Andrew Tridgell ecbfdfba6c HAL_Linux: implement time_shift() API 2013-12-30 14:35:12 +11:00
Andrew Tridgell 91511e6503 HAL_Linux: better realtime setup
lock all memory and pre-fault the stack in all threads
2013-10-08 11:50:53 +11:00
Andrew Tridgell 07b8f45770 HAL_Linux: use CLOCK_MONOTONIC_RAW to ensure clock never goes backwards
this avoids ntp mucking with APM timing
2013-10-07 08:41:52 +11:00
Andrew Tridgell 51c19331a6 HAL_Linux: fixed build 2013-10-01 12:11:48 +10:00
Andrew Tridgell f2ebb2ca87 HAL_Linux: updates for AP_HAL::MemberProc 2013-09-30 20:56:15 +10:00
Andrew Tridgell a1ef1a9318 HAL_Linux: tweak the scheduling priorities 2013-09-29 12:04:37 +10:00
Andrew Tridgell cca59ce3c9 HAL_Linux: update for new scheduler API 2013-09-28 21:24:02 +10:00
Andrew Tridgell bcf4f48e65 HAL_Linux: switched to pthread based scheduling 2013-09-28 21:24:02 +10:00
Andrew Tridgell 4ba044c441 AP_HAL_Linux: initial Linux AP_HAL 2013-09-28 21:24:01 +10:00