From: Simon Wright <simon@pushface.org>
Subject: Re: tasking design for keylock
Date: Fri, 03 Mar 2006 20:48:52 +0000
Date: 2006-03-03T20:48:52+00:00 [thread overview]
Message-ID: <m2bqwn6yq3.fsf@grendel.local> (raw)
In-Reply-To: 1141389368.420323.184550@v46g2000cwv.googlegroups.com
"Rolf" <rolf.ebert_nospam_@gmx.net> writes:
> The following problem arose when I was thinking about the design for a
> minimal tasking runtime system.
>
> Many doors are locked by electronic keylocks where one has to type four
> correct keys on a small keyboard (mostly 0 .. 9, *, #) before the lock
> is opened. Now there are requirements
>
> - that the time between the key presses must not exceed 0.5 seconds,
> - and that after the 4th correct key you must not type any key at all
> for at least 0.5 seconds.
>
> How do you model the timing requirements using Ada tasking? (I can
> attach the h/w interrupt from the key press to a protected procedure,
> but I don't know how to proceed from there, i.e. how to cancel or serve
> a timed entry call now)
I may have misunderstood (and I may have got protected types wrong),
but .. assuming the interrupt handling PO is like
protected Interrupt_Handler is
entry Read_Key (K : out Key);
entry Handler;
pragma Interrupt_Handler (Handler);
private
...
end Interrupt_Handler;
where Read_Key is released by the Handler entry, then you could
select
Interrupt_Handler.Read_Key (K);
or
delay 0.5;
-- deal with missed input opportunity
end select;
-- repeat the above 3 times more
select
Interrupt_Handler.Read_Key (K);
-- deal with additional input
or
delay 0.5;
-- now we have the correct number of characters and no more
end select;
Thad doesn't handle multiple keypresses so close together that they
bunch up in the PO, of course.
next prev parent reply other threads:[~2006-03-03 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-03 12:36 tasking design for keylock Rolf
2006-03-03 13:04 ` Jean-Pierre Rosen
2006-03-03 17:55 ` Dmitry A. Kazakov
2006-03-03 20:48 ` Simon Wright [this message]
2006-03-05 19:27 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox