From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7bb6fcf19a817eb0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsfeed.gamma.ru!Gamma.RU!colt.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: tasking design for keylock Date: Fri, 03 Mar 2006 20:48:52 +0000 Organization: Pushface Message-ID: References: <1141389368.420323.184550@v46g2000cwv.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1141418927 17255 62.49.19.209 (3 Mar 2006 20:48:47 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Fri, 3 Mar 2006 20:48:47 +0000 (UTC) Cancel-Lock: sha1:ijSVfaAxi4ik0CPTLisfyx3SGo4= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news1.google.com comp.lang.ada:3258 Date: 2006-03-03T20:48:52+00:00 List-Id: "Rolf" 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.