mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-13 19:20:51 +08:00
SLEEPQUEUE(9): Fix timeout handling
This commit is contained in:
parent
4ed60d9076
commit
313e1d5f1c
@ -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;
|
||||||
ISR_lock_Context lock_context_2;
|
ISR_lock_Context lock_context_2;
|
||||||
Watchdog_Header *header;
|
Watchdog_Header *header;
|
||||||
|
sbintime_t sbt_per_tick;
|
||||||
uint64_t expire;
|
uint64_t expire;
|
||||||
|
|
||||||
cpu_self = _Thread_Dispatch_disable();
|
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_Set_CPU(&executing->Timer.Watchdog, cpu_self);
|
||||||
|
|
||||||
_Watchdog_Per_CPU_acquire_critical(cpu_self, &lock_context_2);
|
_Watchdog_Per_CPU_acquire_critical(cpu_self, &lock_context_2);
|
||||||
|
sbt_per_tick = rtems_bsd_sbt_per_watchdog_tick;
|
||||||
|
|
||||||
if ((flags & C_ABSOLUTE) != 0) {
|
if ((flags & C_ABSOLUTE) != 0) {
|
||||||
/*
|
/*
|
||||||
* The FreeBSD uptime starts at one second, however, the
|
* The FreeBSD uptime starts at one second, however, the
|
||||||
* relative watchdog ticks start at zero, see also TIMESEL().
|
* 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 {
|
} else {
|
||||||
expire = (sbt + tick_sbt - 1) / tick_sbt;
|
expire = (sbt + sbt_per_tick - 1) / sbt_per_tick;
|
||||||
expire += cpu_self->Watchdog.ticks;
|
expire += cpu_self->Watchdog.ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
|
extern sbintime_t rtems_bsd_sbt_per_watchdog_tick;
|
||||||
|
|
||||||
#define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D')
|
#define BSD_TASK_NAME rtems_build_name('_', 'B', 'S', 'D')
|
||||||
|
|
||||||
struct thread *
|
struct thread *
|
||||||
|
@ -87,6 +87,7 @@ int hz;
|
|||||||
int tick;
|
int tick;
|
||||||
volatile int ticks;
|
volatile int ticks;
|
||||||
sbintime_t tick_sbt;
|
sbintime_t tick_sbt;
|
||||||
|
sbintime_t rtems_bsd_sbt_per_watchdog_tick;
|
||||||
struct bintime bt_timethreshold;
|
struct bintime bt_timethreshold;
|
||||||
struct bintime bt_tickthreshold;
|
struct bintime bt_tickthreshold;
|
||||||
sbintime_t sbt_timethreshold;
|
sbintime_t sbt_timethreshold;
|
||||||
@ -123,6 +124,7 @@ rtems_bsd_initialize(void)
|
|||||||
|
|
||||||
tick = 1000000 / hz;
|
tick = 1000000 / hz;
|
||||||
tick_sbt = SBT_1S / hz;
|
tick_sbt = SBT_1S / hz;
|
||||||
|
rtems_bsd_sbt_per_watchdog_tick = SBT_1S / tps;
|
||||||
FREQ2BT(hz, &tc_tick_bt);
|
FREQ2BT(hz, &tc_tick_bt);
|
||||||
tc_tick_sbt = bttosbt(tc_tick_bt);
|
tc_tick_sbt = bttosbt(tc_tick_bt);
|
||||||
tc_precexp = 31;
|
tc_precexp = 31;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user