Browse Source

Bugfix:hrt is used before it is initalized.

sched_note_{suspend|resume} were calling hrt_absolute_time before
   it hrt_init is called. This can lead to register access before
   clocking is enabled. The result is a hardfault.
sbg
David Sidrane 8 years ago committed by Lorenz Meier
parent
commit
0754e8f8bc
  1. 6
      src/modules/systemlib/cpuload.c

6
src/modules/systemlib/cpuload.c

@ -145,9 +145,10 @@ void sched_note_stop(FAR struct tcb_s *tcb) @@ -145,9 +145,10 @@ void sched_note_stop(FAR struct tcb_s *tcb)
void sched_note_suspend(FAR struct tcb_s *tcb)
{
uint64_t new_time = hrt_absolute_time();
if (system_load.initialized) {
uint64_t new_time = hrt_absolute_time();
for (int i = 0; i < CONFIG_MAX_TASKS; i++) {
/* Task ending its current scheduling run */
if (system_load.tasks[i].valid && system_load.tasks[i].tcb != 0 && system_load.tasks[i].tcb->pid == tcb->pid) {
@ -160,9 +161,10 @@ void sched_note_suspend(FAR struct tcb_s *tcb) @@ -160,9 +161,10 @@ void sched_note_suspend(FAR struct tcb_s *tcb)
void sched_note_resume(FAR struct tcb_s *tcb)
{
uint64_t new_time = hrt_absolute_time();
if (system_load.initialized) {
uint64_t new_time = hrt_absolute_time();
for (int i = 0; i < CONFIG_MAX_TASKS; i++) {
if (system_load.tasks[i].valid && system_load.tasks[i].tcb->pid == tcb->pid) {
system_load.tasks[i].curr_start_time = new_time;

Loading…
Cancel
Save