Message-ID: <5077E531.5050507@xenomai.org> Date: Fri, 12 Oct 2012 11:38:57 +0200 From: Gilles Chanteperdrix MIME-Version: 1.0 References: <5077B799.5000408@xenomai.org> <1350023177-8123-1-git-send-email-gilles.chanteperdrix@xenomai.org> <5077BDEF.6070307@xenomai.org> In-Reply-To: <5077BDEF.6070307@xenomai.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Xenomai] [PATCH 1/1] rtdm: get spinlocks to lock the scheduler List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: xenomai@xenomai.org On 10/12/2012 08:51 AM, Gilles Chanteperdrix wrote: > On 10/12/2012 08:26 AM, Gilles Chanteperdrix wrote: > >> In a context where callbacks are called with spinlocks held, it is not >> possible for drivers callbacks to wake up threads without holding any >> spinlock. So, we need a mechanism to lock the scheduler when a spinlock >> is grabbed. As xnpod_lock_sched/xnpod_unlock_sched may be a bit heavy >> weight for this case, we try and reimplement a lighter version. > > > There is a concurrence issue if, say, xnpod_suspend_thread or > xnpod_reset_thread is called on another cpu while the thread which holds > the scheduler lock is using an rtdm spinlock. I guess the rtdm spinlocks > have to take the nklock to serialize access to the scheduler structures, > so, use xnpod_lock_sched/xnpod_unlock_sched instead of > __xnpod_lock_sched / __xnpod_unlock_sched. Doesn't work either. So, handling the scheduler lock has to take place in xnpod_schedule. What we can simply do is add a shortcut for this case in __xnpod_schedule. -- Gilles.