"Semaphore" with thumb code

OP #1174585
Hello,

I have a following situation with Yagarto and AT91SAM7X:

Interrupt routine counts interrupts;

...
++signals;
...

In main loop, I need to do further processing based
on received signals (I want to keep interrupts lightweight,
so only minimal amount of work should be done there)

...
somevalue = signals*somescaler;
signals = 0;
...


Now, this is very thread-unsafe. But how can I do this safely with thumb
instruction set? No swp in thumb set, and load/store combination isn't
very atomic, and  the disabling interrupts apparently is troublesome
too:

I understood that disabling interrupts with AIC_IECR->IDCR causes
spurious interrupts, but could that really cause extra interrupts (ISR
called twice if it triggers at bad moment) or does that interrupt just
get served late? ISR getting server late would be no problem, since I
can do necessary processing fast enough to not miss interrupts, but how
is the situation exactly?

Now, another thing that isn't clear to me is thumb-interwork -mode. In
which situations that is needed exactly? For practical example, if I
have for example thumb module calling ARM (to access that precious swp
for example), how should I do that?
Non-interwork thumb-module calls interwork-thumb module that calls ARM
module, or how? (that single swp or access to global interrupt flag gets
really expensive really fast this way...)

Reply

A question of your own? This thread is over 17 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.