Board index » delphi » Interrupt Clock (Can't WRITE to disk)

Interrupt Clock (Can't WRITE to disk)

Quote
On Thu, 21 Nov 1996 18:58:38 +0000, Neil Jaques wrote:
>I recently decided to add a clock to my database, I am designing, one
>that uses interrupts instead of loops.
>Now the problem is that it seems to be conflicting with writing to the
>A: and the computer totally hangs, you can't CTRL-BREAK, or even Warm
>Boot the computer.
[...]
>PROCEDURE Timehandler; INTERRUPT;
[...]
>     GetTime(Hr,Min,Sec,Hund);

procedure GetTime is realized using a DOS call (function $2C of Int
$21)

DOS is NOT reentrant!
You cannot use any DOS call in an interrupt routine

Solutions:

1. var TimeTicks: LongInt absolute $40:$6C;
   and calculate values h, m, s "manualy"
   (one tick every 55ms)

2. INT $1A - is expanded in the AT BIOS to set/read RTC
   (real time clock). Function 2 returns:
   CH - hours, CL - minutes, DH - seconds.
   All values in BCD

3. A patch to INT $21 to avoid "DOS call during DOS call"

Grego

P.S.

Quote
>     STR(Hr:0, H);
>     STR(Min:0, M);
>     STR(Sec:0, S);

Also the procedure Str is not reentrant.
If your program uses Str
    [attention: "invisibile Str" too!
     for example WriteLn( n ) where n is a number]
  you can't use Str inside any interrupt service routine.
  But write a two-digit integer -> ASCII conversion is easy.

P.S.2. The art of writing interrupt service routines asks
  a very good preparation.

--

/-----------------------------------------------------------------
Gregorio Kus    Gr...@RMnet.it                Gr...@{*word*104}space.org
ROMA, Italy     http://www.RMnet.it/~grego    Gr...@FreeNet.hut.fi
Anonymous Mail Service - http://free.rmnet.it/~grego/AnonMail.html

 

Re:Interrupt Clock (Can't WRITE to disk)


Quote
>I recently decided to add a clock to my database, I am designing, one
>that uses interrupts instead of loops.
>Now the problem is that it seems to be conflicting with writing to the
>A: and the computer totally hangs, you can't CTRL-BREAK, or even Warm
>Boot the computer.
>I would appreciated any help in this matter and below I have enclosed my
>code, which I obtained form this newsgroup along time ago.

One problem I see is you are calling a DOS function from within an  
interrupt handler.  This is a no-no if you don't check to make sure DOS  
isn't busy first.  DOS calls are non-reenterent and you can corrupt the  
stack.  You're also spending alot of time in the interrupt handler, which  
could cause other interrupt to be missed.  I feel you would be better off  
just placing a clock update routine within your main loop, I usually put  
it in a loop that waits for keyboard strokes.

Other Threads