[haiku-commits] Re: BRANCH pdziepak-github.scheduler [d8fcc8a] src/system/kernel headers/private/kernel src/system/kernel/scheduler

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 31 Oct 2013 18:32:52 +0100

On 10/31/2013 02:15 AM, pdziepak-github.scheduler wrote:
added 1 changeset to branch 'refs/remotes/pdziepak-github/scheduler'
old head: c8dd9f7780c426e592a3ccb231e6bfab51f15eb9
new head: d8fcc8a82519cef977c689cee497316be6f1531f
overview: https://github.com/pdziepak/Haiku/compare/c8dd9f7...d8fcc8a

----------------------------------------------------------------------------

d8fcc8a: 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.

The main purpose of the lock is to prevent the race condition *while ...

   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.

... avoiding this wait*. This is meant for situations where cancel_timer() must be invoked in a critical section protected by a spinlock that also needs to be acquired in the event handler. Waiting would mean a deadlock.

The solution was to require cancel_timer() to be invoked with a spinlock held that can be acquired right before invoking the event handler (rechecking whether the event was canceled first). The scheduler lock was chosen, because it was already needed in some places (e.g. the thread blocking API).

So please carefully review the code using this feature under this aspect.

CU, Ingo


Other related posts: