* 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
This commit is contained in:
Ingo Weinhold
2008-04-22 15:29:22 +00:00
parent 1201d52e6c
commit e01cebeb0a
5 changed files with 317 additions and 284 deletions
+3 -3
View File
@@ -15,13 +15,13 @@ extern "C" {
struct kernel_args;
#define B_TIMER_ACQUIRE_THREAD_LOCK 0x8000
#define B_TIMER_FLAGS B_TIMER_ACQUIRE_THREAD_LOCK
/* kernel functions */
status_t timer_init(struct kernel_args *);
int32 timer_interrupt(void);
/* this one is only to be used by the scheduler */
status_t _local_timer_cancel_event(int currentCPU, timer *event);
#ifdef __cplusplus
}
#endif