History log of /haiku/src/system/kernel/timer.cpp
Revision Date Author Comments
# f1b2d3ba 24-Feb-2022 Alexander von Gluck IV <kallisti5@unixzen.com>

kernel/x86: Fix and modernize tracing of timer code; no functional change

* Fixes functionality of TRACE statements on 64-bit platforms.

Change-Id: Iaba8f8b2d49ec1acda3fc2d51e24a207c5bcc97a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4992
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# e6ea745e 06-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Use SMP_MAX_CPUS instead of B_MAX_CPU_COUNT


# 7db89e8d 25-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Rework cpuidle module

* Create new interface for cpuidle modules (similar to the cpufreq
interface)
* Generic cpuidle module is no longer needed
* Fix and update Intel C-State module


# 73ad2473 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

Remove remaining unnecessary 'volatile' qualifiers


# d8fcc8a8 30-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Remove B_TIMER_ACQUIRE_SCHEDULER_LOCK flag

The flag main purpose is to avoid race conditions between event handler
and cancel_timer(). However, cancel_timer() is safe even without
using gSchedulerLock.

If the event is scheduled to happen on other CPU than the CPU that
invokes cancel_timer() then cancel_timer() either disables the event
before its handler starts executing or waits until the event handler
is done.

If the event is scheduled on the same CPU that calls cancel_timer()
then, since cancel_timer() disables interrupts, the event is either
executed before cancel_timer() or when the timer interrupt handler
starts running the event is already disabled.


# 920e575c 20-Aug-2011 Jérôme Duval <korli@users.berlios.de>

As suggested by Ingo, revert r42648 and apply patch from Alex Smith provided in #7872. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42650 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d29d58ed 20-Aug-2011 Jérôme Duval <korli@users.berlios.de>

Disable interrupts when updating real time clock. Fixes #7872. Seems to have been introduced in r42116.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42648 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24df6592 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d74f5f5b 18-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Cleaned up the code which also closes CID 176 which was not a bug, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38228 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03bab654 17-Feb-2010 Stefano Ceccherini <stefano.ceccherini@gmail.com>

set_hardware_timer() would sometimes (on boot) pass a negative timeout to
arch_timer_set_hardware_timer(). This was harmless, at least with our
current x86 timers implementation, since they checked for minimum timeouts.
Very small cleanup (now that the file is compiled as C++).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35505 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0338371f 13-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* All scheduler implementations:
- enqueue_in_run_queue() no longer returns whether rescheduling is supposed
to happen. Instead is sets cpu_ent::invoke_scheduler on the current CPU.
- reschedule() does now handle cpu_ent::invoke_scheduler_if_idle(). No need
to let all callers do that.
* thread_unblock[_locked]() no longer return whether rescheduling is supposed
to happen.
* Got rid of the B_INVOKE_SCHEDULER handling. The interrupt hooks really
can't know, when it makes sense to reschedule or not.
* Introduced scheduler_reschedule_if_necessary[_locked]() functions for
checking+invoking the scheduler.
* Some semaphore functions (e.g. delete_sem()) invoke the scheduler now, if
they wake up anything with greater priority.
I've also tried to add scheduler invocations in the condition variable and
mutex/rw_lock code, but that actually has a negative impact on performance,
probably because it causes too much ping-ponging between threads when
multiple locking primitives are involved.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34657 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10b48331 10-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

When any of the executed timer hooks return B_INVOKE_SCHEDULER, let
timer_interrupt() return B_INVOKE_SCHEDULER. The scheduler itself uses a
timer hook and relies on scheduler_reschedule() to be called. Will make this
even more reliable in the next commit.
This might fix #3535.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1412a38e 15-Sep-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed build with tracing enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33153 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 78c90d44 17-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved definition of the PAUSE macro to <cpu.h>, respectively
<arch/cpu.h>.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43bae015 22-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Made waiting for a timer handler more power usage friendly.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25101 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e01cebeb 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* cancel_timer():
- If the hook of the timer we're cancelling is currently being
executed, we do now wait till it is finished. This is how the BeBook
specifies the function to behave.
- Periodic timers would not be cancelled, if their hook was being
invoked at the same time, since they weren't in the queue during
that time.
- Since we know the CPU on which the timer is scheduled (timer::cpu),
we don't have to look through any other CPU queue to find it.
- Fixed the return value. It should report whether the timer had
already fired, and was not always doing that.
* Added private add_timer() flag B_TIMER_ACQUIRE_THREAD_LOCK. It causes
the thread spinlock to be acquired before the event hook is called.
cancel_timer() doesn't wait for timers with the flag set. Instead we
check in the timer interrupt function after acquiring the thread
spinlock whether the timer was cancelled in the meantime. Calling
cancel_timer() with the thread spinlock being held does thus avoid any
race conditions and won't deadlock, if the event hook needs to acquire
the thread spinlock, too. This feature proves handy for some kernel
internal needs.
* The scheduler uses a B_TIMER_ACQUIRE_THREAD_LOCK timer now and
cancel_timer() instead of the no longer needed
_local_timer_cancel_event().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25098 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e6ea745e8114d5fa05ab0ccab92c070e2dcdcfb7 06-Dec-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Use SMP_MAX_CPUS instead of B_MAX_CPU_COUNT


# 7db89e8dc395db73368479fd9817b2b67899f3f6 25-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Rework cpuidle module

* Create new interface for cpuidle modules (similar to the cpufreq
interface)
* Generic cpuidle module is no longer needed
* Fix and update Intel C-State module


# 73ad2473e7874b3702cf5b0fdf4c81b747812ed9 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

Remove remaining unnecessary 'volatile' qualifiers


# d8fcc8a82519cef977c689cee497316be6f1531f 30-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Remove B_TIMER_ACQUIRE_SCHEDULER_LOCK flag

The flag main purpose is to avoid race conditions between event handler
and cancel_timer(). However, cancel_timer() is safe even without
using gSchedulerLock.

If the event is scheduled to happen on other CPU than the CPU that
invokes cancel_timer() then cancel_timer() either disables the event
before its handler starts executing or waits until the event handler
is done.

If the event is scheduled on the same CPU that calls cancel_timer()
then, since cancel_timer() disables interrupts, the event is either
executed before cancel_timer() or when the timer interrupt handler
starts running the event is already disabled.


# 920e575c03b4817d93424a4ed7bc46a5ed288660 20-Aug-2011 Jérôme Duval <korli@users.berlios.de>

As suggested by Ingo, revert r42648 and apply patch from Alex Smith provided in #7872. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42650 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d29d58edea46b77c78722316bab366692caf9691 20-Aug-2011 Jérôme Duval <korli@users.berlios.de>

Disable interrupts when updating real time clock. Fixes #7872. Seems to have been introduced in r42116.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42648 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24df65921befcd0ad0c5c7866118f922da61cb96 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d74f5f5bb51485853cadc63faf7b5363dbf64210 18-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Cleaned up the code which also closes CID 176 which was not a bug, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38228 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03bab65450ac8c8b7da9678477b1328ce9d1d855 17-Feb-2010 Stefano Ceccherini <stefano.ceccherini@gmail.com>

set_hardware_timer() would sometimes (on boot) pass a negative timeout to
arch_timer_set_hardware_timer(). This was harmless, at least with our
current x86 timers implementation, since they checked for minimum timeouts.
Very small cleanup (now that the file is compiled as C++).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35505 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0338371f26864c2a248b1ea53b9fe78c884af7f2 13-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* All scheduler implementations:
- enqueue_in_run_queue() no longer returns whether rescheduling is supposed
to happen. Instead is sets cpu_ent::invoke_scheduler on the current CPU.
- reschedule() does now handle cpu_ent::invoke_scheduler_if_idle(). No need
to let all callers do that.
* thread_unblock[_locked]() no longer return whether rescheduling is supposed
to happen.
* Got rid of the B_INVOKE_SCHEDULER handling. The interrupt hooks really
can't know, when it makes sense to reschedule or not.
* Introduced scheduler_reschedule_if_necessary[_locked]() functions for
checking+invoking the scheduler.
* Some semaphore functions (e.g. delete_sem()) invoke the scheduler now, if
they wake up anything with greater priority.
I've also tried to add scheduler invocations in the condition variable and
mutex/rw_lock code, but that actually has a negative impact on performance,
probably because it causes too much ping-ponging between threads when
multiple locking primitives are involved.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34657 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 10b4833178c6f4d7d9c8ccabe669bac9e5a98b96 10-Dec-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

When any of the executed timer hooks return B_INVOKE_SCHEDULER, let
timer_interrupt() return B_INVOKE_SCHEDULER. The scheduler itself uses a
timer hook and relies on scheduler_reschedule() to be called. Will make this
even more reliable in the next commit.
This might fix #3535.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34614 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1412a38e9bcae2f3f97c7f2e0a6df2a241a36d30 15-Sep-2009 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Fixed build with tracing enabled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33153 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 78c90d44cad4b0e03bdd9d0590525d07dafb3bc4 17-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved definition of the PAUSE macro to <cpu.h>, respectively
<arch/cpu.h>.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28221 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 43bae0150894a08424f8e9cc4783e9a9e0c8bb38 22-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Made waiting for a timer handler more power usage friendly.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25101 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e01cebeb0afabb44d9a14013bc82863ef3648e2e 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* cancel_timer():
- If the hook of the timer we're cancelling is currently being
executed, we do now wait till it is finished. This is how the BeBook
specifies the function to behave.
- Periodic timers would not be cancelled, if their hook was being
invoked at the same time, since they weren't in the queue during
that time.
- Since we know the CPU on which the timer is scheduled (timer::cpu),
we don't have to look through any other CPU queue to find it.
- Fixed the return value. It should report whether the timer had
already fired, and was not always doing that.
* Added private add_timer() flag B_TIMER_ACQUIRE_THREAD_LOCK. It causes
the thread spinlock to be acquired before the event hook is called.
cancel_timer() doesn't wait for timers with the flag set. Instead we
check in the timer interrupt function after acquiring the thread
spinlock whether the timer was cancelled in the meantime. Calling
cancel_timer() with the thread spinlock being held does thus avoid any
race conditions and won't deadlock, if the event hook needs to acquire
the thread spinlock, too. This feature proves handy for some kernel
internal needs.
* The scheduler uses a B_TIMER_ACQUIRE_THREAD_LOCK timer now and
cancel_timer() instead of the no longer needed
_local_timer_cancel_event().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25098 a95241bf-73f2-0310-859d-f6bbb57e9c96