Re: spin lock
- From: Elizabeth D Rather <eratherXXX@xxxxxxxxx>
- Date: Sat, 25 Aug 2007 13:40:46 -1000
Marcel Hendrix wrote:
Elizabeth D Rather <eratherXXX@xxxxxxxxx> writes Re: spin lock
[..]
Marcel Hendrix wrote:[..]Elizabeth D Rather <eratherXXX@xxxxxxxxx> wrote Re: spin lockWhat happens if a task has the lock/variable and interrupt code needs it?
The interrupt has to silently fail then? Or should the design be that it
can (almost) always run and wake a dedicated, pausable,TASK to further handle the problem? (This postpones the problem until it becomes a real error).
If a task is requesting service from a shared device, it should GET the device before making the service request, then sleep. Interrupt code can complete the time-critical part of the service, then RELEASE the device and awaken the task to do further processing, if any.
Neat. That would save an extra task, but if the interrupt for some reason
does not come because it is missing a period, the system might need to be
aborted.
I suppose some devices might need a time-out. That's not been my experience, though.
It should never happen that a totally unexpected interrupt occurs for a shared device. Some task should be expecting it, having done a GET. A nice side-effect of this scheme is that the GET associates the task handle with the facility, so the interrupt code knows who is expecting the interrupt and hence whom to wake up.
Wouldn't it be rather dangerous for the IRQ handler to do this? The task
could be in the (interrupted) process of being woken up because of a time
out, kill or something... Stopping the IRQ would kill the task, while
stopping the task might not prevent the IRQ from waking it inappropriately.
"Waking up a task" from an IRQ merely involves setting a code in its status cell. It's pretty non-violent, and if the task is already waking up it's a no-op. And we don't kill tasks. We do have a word:
: NOD ( -- ) BEGIN STOP AGAIN ;
....which you can assign a task to do when it isn't doing anything else, in case an interrupt it's associated with wakes it up inappropriately. But normally the task wouldn't GET a facility unless it expected to do something with it.
I see the SwiftForth reference manual has a good discussion on GET and RELEASE.
Yeah, they work pretty much the same in SwiftForth, although the multitasking is completely different. The SwiftOS multitasker is found in SwiftX targets.
Cheers,
Elizabeth
--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310-491-3356
5155 W. Rosecrans Ave. #1018 Fax: +1 310-978-9454
Hawthorne, CA 90250
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
==================================================
.
- References:
- Re: spin lock
- From: Elizabeth D Rather
- Re: spin lock
- From: Marcel Hendrix
- Re: spin lock
- Prev by Date: Re: spin lock
- Next by Date: Re: spin lock
- Previous by thread: Re: spin lock
- Next by thread: Re: spin lock
- Index(es):
Relevant Pages
|