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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: tasking design for keylock Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1141389368.420323.184550@v46g2000cwv.googlegroups.com> Date: Fri, 3 Mar 2006 18:55:09 +0100 Message-ID: NNTP-Posting-Date: 03 Mar 2006 18:55:06 MET NNTP-Posting-Host: a23719ea.newsread4.arcor-online.net X-Trace: DXC=X]K?klNhn2YHDP On 3 Mar 2006 04:36:08 -0800, Rolf wrote: > 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) You can implement your FSM directly in the protected object. Timing constraints will be checked in the protected procedure attached to the keypad interrupt. This procedure will change the state (of the FSM) according to your diagram. The state "Open" can be used as a barrier for the entry Open. This entry can be then waited for from some (or several) external task. You will also need protected procedure attached to the door/lock interrupt (I presume that it closes automatically after some delay.) It seems to me that you need no tasks to control the lock. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de