Changeset 5e093a5 in rtems-libbsd


Ignore:
Timestamp:
Feb 22, 2017, 10:49:33 AM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
fd86c091b97759106da7355ce1dd81ebe030e285, f020f08430150c1656a0ad0a1de13699db9b980b
Children:
631fb98
Parents:
2a5d001
git-author:
Sebastian Huber <sebastian.huber@…> (02/22/17 10:49:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/28/17 09:07:30)
Message:

SLEEPQUEUE(9): Fix absolute timeouts

The FreeBSD kernel timeouts are always based on the uptime. Thus, we
have to use the relative watchdog. C_ABSOLUTE just means that the
timeout value is already an uptime value.

https://lists.freebsd.org/pipermail/freebsd-hackers/2017-February/050572.html

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sys/kern/subr_sleepqueue.c

    r2a5d001 r5e093a5  
    449449        Per_CPU_Control *cpu_self;
    450450        Thread_Control *executing;
     451        ISR_lock_Context lock_context;
     452        ISR_lock_Context lock_context_2;
     453        Watchdog_Header *header;
     454        uint64_t expire;
    451455
    452456        cpu_self = _Thread_Dispatch_disable();
     
    455459            WATCHDOG_INACTIVE);
    456460
    457         if ((flags & C_ABSOLUTE) == 0) {
    458                 _Thread_Timer_insert_relative(executing, cpu_self, sleepq_timeout,
    459                     (Watchdog_Interval)((sbt + tick_sbt - 1) / tick_sbt));
     461        _ISR_lock_ISR_disable_and_acquire(&executing->Timer.Lock, &lock_context);
     462
     463        header = &cpu_self->Watchdog.Header[PER_CPU_WATCHDOG_RELATIVE];
     464        executing->Timer.header = header;
     465        executing->Timer.Watchdog.routine = sleepq_timeout;
     466        _Watchdog_Set_CPU(&executing->Timer.Watchdog, cpu_self);
     467
     468        _Watchdog_Per_CPU_acquire_critical(cpu_self, &lock_context_2);
     469
     470        if ((flags & C_ABSOLUTE) != 0) {
     471                /*
     472                 * The FreeBSD uptime starts at one second, however, the
     473                 * relative watchdog ticks start at zero, see also TIMESEL().
     474                 */
     475                expire = (sbt - SBT_1S + tick_sbt - 1) / tick_sbt;
    460476        } else {
    461                 _Thread_Timer_insert_absolute(executing, cpu_self, sleepq_timeout,
    462                     _Watchdog_Ticks_from_sbintime(sbt));
    463         }
    464 
     477                expire = (sbt + tick_sbt - 1) / tick_sbt;
     478                expire += cpu_self->Watchdog.ticks;
     479        }
     480
     481        _Watchdog_Insert(header, &executing->Timer.Watchdog, expire);
     482        _Watchdog_Per_CPU_release_critical(cpu_self, &lock_context_2);
     483        _ISR_lock_Release_and_ISR_enable(&executing->Timer.Lock, &lock_context);
    465484        _Thread_Dispatch_direct(cpu_self);
    466485#endif /* __rtems__ */
Note: See TracChangeset for help on using the changeset viewer.