[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fwd: [rtl] Preventing a task from being interrupted]



Ivan Martinez wrote:
> 
> Stuart Hughes wrote:
> >
> > Ivan Martinez wrote:
> > >
> > >         Hello!
> > >         I have some real time tasks/threads sharing some variables, so I would
> > > like to prevent them from being interrupted by other task when reading
> > > or writing them. How can I do that?. Do I get what I want with
> > > "rtl_no_iterrupts"?.
> > >         Thank you!.
> >
> > Hi Ivan,
> >
> > I use the following wrappers:
> >
> > #ifdef CONFIG_RTL
> >
> > #include <asm/rtl_sync.h>
> > #undef cli()
> > #undef sti()
> > #undef save_flags(x)
> > #undef restore_flags(x)
> > #define sti()
> > #define cli()
> > #define save_flags(x)  rtl_hard_savef_and_cli(x)
> > #define restore_flags(x) rtl_hard_restore_flags(x)
> >
> > #else
> > .....
> >
> > Then you can just use save_flags(flags) and restore_flags(flags) pairs.
> > It works on a uniprocessor, but there may well be a better way.
> >
> > Regards, Stuart
> 
>         I can't understand very well what you do with that. Could somebody
> explain me a bit about it?. Any simpler way of doing what I want?. Thank
> you.

Hi Ivan,

To simplify what I was saying, for RTLinux, you need to isolate your
code using the following (the complication above makes sure that the
correct calls get made).

unsigned long flags;

// critical section, disable interrrupts
rtl_hard_savef_and_cli(flags)
.
.
.
.
// restore interrupts
rtl_hard_restore_flags(flags)


Sorry that my previous answer was so obscure.

Regards, Stuart