But you might do it with addq/subq
sema: dc.l -1
subq.l #1,sema ; restore "old" value
;; critical code
;; return semaphore
subq.l #1,sema ; set to -1
I have a MC332 running at 16 Mhz.
(1) The set up:
I have the periodic timer interrupt (PIT) interrupting every 977
microseconds (~1000 Hz). In every interrupt I do increment a
number of "tick" counter variables relative to the 977 microsecond
PIT interrupt. Later in the code I have 'if' staments wich
execute every time the corresponding tick counter reaches a number
close to say 50 Hz, 25 Hz, 5 Hz since I am attempting to execute
different tasks at different rates asynchronously.
(2) The problem:
Since I am accessing a common database, I am afraid that I have
(eventually) some memory access conflicts where a 50 Hz
'if' statement reads from memory and an interrupt occurs. I wonder
if I can attribute some quasi-periodic misbehavior or data
corruption to this time conflicts? Basically, I am concerned with
read-modify-write or just write-to-memory type of conflicts.
(3) The question:
My question then boils down to how can I implement a fire-sure
data access semaphore scheme? I have tried several schemes, but
have been unsuccessful. May be the solution is simple and in front
of my nose, but I do not see it!
In any event, I am sure that I am reinventing the wheel in
this one case, and I'll appreciate any help in this regard!
School of Aerospace and Mechanical Engineering
University of Oklahoma
Ph: (405) 325-5052
Fax: (405) 325-1088