comp.lang.ada
 help / color / mirror / Atom feed
* Interrupt problem in GNAT
@ 1999-05-19  0:00 Joerg Kienzle
  1999-05-19  0:00 ` David C. Hoos, Sr.
  0 siblings, 1 reply; 4+ messages in thread
From: Joerg Kienzle @ 1999-05-19  0:00 UTC (permalink / raw)



Hi,

I am running gnat 3.11w on Solaris, and I am trying to use interrupts to
perform a periodic operation. I have declared the following package:

with Ada.Interrupts; use Ada.Interrupts;
with Ada.Interrupts.Names; use Ada.Interrupts.Names;

package Clocks is

   protected Clock is
      procedure Tick;
      pragma Interrupt_Handler (Tick);
      pragma Attach_Handler (Tick, SIGALRM);
   end Clock;

end Clocks;

And the body:

package body Clocks is

   protected body Clock is

      procedure Tick is
      begin
	--  Do something here
      end Tick;

   end Clock;

end Clocks;

As you can see in the spec, I am trying to attach the Tick procedure
to the SIGALRM signal. In my main procedure, I use the operating
system functions timer_create and timer_settime to tell the OS to
send SIGALRM to my process every x seconds.
This works; the process gets a SIGALRM signal, but my handler function
in not called! Instead, "Alarm clock" is printed on the terminal and
the process exits...
The same thing happens if I use the "alarm" function to send
the SIGALRM signal:

with Interfaces.C;
with Clocks;

procedure Main is

   procedure Alarm (Sec : C.Unsigned);
   pragma Import (C, Alarm, "alarm");

   procedure Set_Alarm (I : in Natural);

   procedure Set_Alarm (I : in Natural) is
   begin
      Alarm (C.Unsigned (I));
   end Set_Alarm;

begin

   Set_Alarm (5);

   while True loop
      null;
   end loop;

end Main;


I tried other signals, but I still doesn't work.
What am I doing wrong?

- J�rg

-- 
---------------------------------------------------------------------------
- Joerg Kienzle - Swiss Federal Institue of Technology - CH-1015
Lausanne -
- email : Joerg.Kienzle@epfl.ch    WWW :
http://lglwww.epfl.ch/~jkienzle/ -
- phone : ++41 21 693 42 37        fax : ++41 21 693 50
79                -




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-05-20  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-19  0:00 Interrupt problem in GNAT Joerg Kienzle
1999-05-19  0:00 ` David C. Hoos, Sr.
1999-05-20  0:00   ` Joerg Kienzle
1999-05-20  0:00     ` David C. Hoos, Sr.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox