SLEEPQUEUE(9): Fix timeout handling

This commit is contained in:
Sebastian Huber 2019-07-05 10:18:42 +02:00
parent 4ed60d9076
commit 313e1d5f1c
3 changed files with 8 additions and 2 deletions

View File

@ -462,6 +462,7 @@ sleepq_set_timeout_sbt(void *wchan, sbintime_t sbt, sbintime_t pr,
ISR_lock_Context lock_context;
ISR_lock_Context lock_context_2;
Watchdog_Header *header;
sbintime_t sbt_per_tick;
uint64_t expire;
cpu_self = _Thread_Dispatch_disable();
@ -477,15 +478,16 @@ sleepq_set_timeout_sbt(void *wchan, sbintime_t sbt, sbintime_t pr,
_Watchdog_Set_CPU(&executing->Timer.Watchdog, cpu_self);
_Watchdog_Per_CPU_acquire_critical(cpu_self, &lock_context_2);
sbt_per_tick = rtems_bsd_sbt_per_watchdog_tick;
if ((flags & C_ABSOLUTE) != 0) {
/*
* The FreeBSD uptime starts at one second, however, the
* relative watchdog ticks start at zero, see also TIMESEL().
*/
expire = (sbt - SBT_1S + tick_sbt - 1) / tick_sbt;
expire = (sbt - SBT_1S + sbt_per_tick - 1) / sbt_per_tick;
} else {
expire = (sbt + tick_sbt - 1) / tick_sbt;
expire = (sbt + sbt_per_tick - 1) / sbt_per_tick;
expire += cpu_self->Watchdog.ticks;
}

View File

@ -46,6 +46,8 @@
#include <rtems.h>
extern sbintime_t rtems_bsd_sbt_per_watchdog_tick;
#define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D')
struct thread *

View File

@ -87,6 +87,7 @@ int hz;
int tick;
volatile int ticks;
sbintime_t tick_sbt;
sbintime_t rtems_bsd_sbt_per_watchdog_tick;
struct bintime bt_timethreshold;
struct bintime bt_tickthreshold;
sbintime_t sbt_timethreshold;
@ -123,6 +124,7 @@ rtems_bsd_initialize(void)
tick = 1000000 / hz;
tick_sbt = SBT_1S / hz;
rtems_bsd_sbt_per_watchdog_tick = SBT_1S / tps;
FREQ2BT(hz, &tc_tick_bt);
tc_tick_sbt = bttosbt(tc_tick_bt);
tc_precexp = 31;