* [Xenomai] Make a block of code atomic
@ 2013-07-09 11:40 Paolo Minazzi
2013-07-10 11:37 ` Gilles Chanteperdrix
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Minazzi @ 2013-07-09 11:40 UTC (permalink / raw)
To: xenomai
Hi,
I would like to make a block of kernel code atomic, so that no one (both
xenomai and Linux) can interrupt it.
I use the following :
#define my_local_irq_save(x) ((x) =
ipipe_test_and_stall_pipeline_head() & 1)
#define my_local_irq_restore(x) ipipe_restore_pipeline_head(x)
my_local_irq_save(flags);
< critical section >
my_local_irq_restore(flags);
It works well enough, but rarely an rtdm irq enter into my critical
section.
The rtdm irq is registered in this way : rtdm_irq_request(&priv->irqHnd,
ETH_PORT_IRQ_NUM(priv->port), irqHandler, RTDM_IRQTYPE_EDGE, "rtdm_eth",
priv);
Is it normal ? Are you sure that it cannot happen ?
Thanks,
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai] Make a block of code atomic
2013-07-09 11:40 [Xenomai] Make a block of code atomic Paolo Minazzi
@ 2013-07-10 11:37 ` Gilles Chanteperdrix
2013-07-10 11:46 ` Paolo Minazzi
0 siblings, 1 reply; 3+ messages in thread
From: Gilles Chanteperdrix @ 2013-07-10 11:37 UTC (permalink / raw)
To: Paolo Minazzi; +Cc: xenomai
On 07/09/2013 01:40 PM, Paolo Minazzi wrote:
> Hi,
>
> I would like to make a block of kernel code atomic, so that no one (both
> xenomai and Linux) can interrupt it.
> I use the following :
>
> #define my_local_irq_save(x) ((x) =
> ipipe_test_and_stall_pipeline_head()& 1)
> #define my_local_irq_restore(x) ipipe_restore_pipeline_head(x)
>
> my_local_irq_save(flags);
> < critical section>
> my_local_irq_restore(flags);
>
> It works well enough, but rarely an rtdm irq enter into my critical
> section.
> The rtdm irq is registered in this way : rtdm_irq_request(&priv->irqHnd,
> ETH_PORT_IRQ_NUM(priv->port), irqHandler, RTDM_IRQTYPE_EDGE, "rtdm_eth",
> priv);
>
> Is it normal ? Are you sure that it cannot happen ?
Looking at ipipe_test_and_stall_head implementation on the I-pipe patch
for Linux 3.8:
static inline unsigned long ipipe_test_and_stall_head(void)
{
hard_local_irq_disable();
return __test_and_set_bit(IPIPE_STALL_FLAG, &__ipipe_head_status);
}
getting an interrupt in your critical section would mean that
"hard_local_irq_disable" is broken on the architecture where you use it.
That being said, I do not know if I look at the implementation you are
using, since you did not give us any information about version and
architecture you are using.
--
Gilles.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Xenomai] Make a block of code atomic
2013-07-10 11:37 ` Gilles Chanteperdrix
@ 2013-07-10 11:46 ` Paolo Minazzi
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Minazzi @ 2013-07-10 11:46 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
Il 10/07/2013 13.37, Gilles Chanteperdrix ha scritto:
> On 07/09/2013 01:40 PM, Paolo Minazzi wrote:
>
>> Hi,
>>
>> I would like to make a block of kernel code atomic, so that no one (both
>> xenomai and Linux) can interrupt it.
>> I use the following :
>>
>> #define my_local_irq_save(x) ((x) =
>> ipipe_test_and_stall_pipeline_head()& 1)
>> #define my_local_irq_restore(x) ipipe_restore_pipeline_head(x)
>>
>> my_local_irq_save(flags);
>> < critical section>
>> my_local_irq_restore(flags);
>>
>> It works well enough, but rarely an rtdm irq enter into my critical
>> section.
>> The rtdm irq is registered in this way : rtdm_irq_request(&priv->irqHnd,
>> ETH_PORT_IRQ_NUM(priv->port), irqHandler, RTDM_IRQTYPE_EDGE, "rtdm_eth",
>> priv);
>>
>> Is it normal ? Are you sure that it cannot happen ?
>
>
> Looking at ipipe_test_and_stall_head implementation on the I-pipe
> patch for Linux 3.8:
>
> static inline unsigned long ipipe_test_and_stall_head(void)
> {
> hard_local_irq_disable();
> return __test_and_set_bit(IPIPE_STALL_FLAG, &__ipipe_head_status);
> }
>
> getting an interrupt in your critical section would mean that
> "hard_local_irq_disable" is broken on the architecture where you use it.
>
> That being said, I do not know if I look at the implementation you are
> using, since you did not give us any information about version and
> architecture you are using.
>
Hi Gilles, thanks for your answer.
I found this morning that was linux to re-enable interrupts.
The following
#define my_local_irq_save(x) ((x) =
ipipe_test_and_stall_pipeline_head()& 1)
#define my_local_irq_restore(x) ipipe_restore_pipeline_head(x)
works well if no one touch irq flags directly. Unfortunately was not my
case.
Thanks again,
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-10 11:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-09 11:40 [Xenomai] Make a block of code atomic Paolo Minazzi
2013-07-10 11:37 ` Gilles Chanteperdrix
2013-07-10 11:46 ` Paolo Minazzi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.