comp.lang.ada
 help / color / mirror / Atom feed
From: Joerg Kienzle <Joerg.Kienzle@epfl.ch>
Subject: Interrupt problem in GNAT
Date: 1999/05/19
Date: 1999-05-19T00:00:00+00:00	[thread overview]
Message-ID: <3742DC0D.B8F07A52@epfl.ch> (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                -




             reply	other threads:[~1999-05-19  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-19  0:00 Joerg Kienzle [this message]
1999-05-19  0:00 ` Interrupt problem in GNAT David C. Hoos, Sr.
1999-05-20  0:00   ` Joerg Kienzle
1999-05-20  0:00     ` David C. Hoos, Sr.
replies disabled

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