comp.lang.ada
 help / color / mirror / Atom feed
From: Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Subject: Re: help about handling interrupts
Date: 1998/04/07
Date: 1998-04-07T00:00:00+00:00	[thread overview]
Message-ID: <352A14FA.6E9E4778@cl.cam.ac.uk> (raw)
In-Reply-To: matthew_heaney-ya023680000704980000060001@news.ni.net


Matthew Heaney wrote:
> Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk> wrote:
> >User processes cannot directly handle interrupts under Linux.
> >If you want to write an interrupt handler yourself, you have to
> >do this in a loadable kernel module. You can write loadable kernel
> >modules in Ada just like you can do this in C. You have to call a
> >kernel function at module load time that registers your Ada
> >procedure as an interrupt handler, and then the Linux kernel
> >will call your Ada procedure whenever this interrupt comes in.
> 
> I don't understand this response.
> 
> In Ada 95, you attach protected procedure of a protected object to an
> interrupt.  Section 19.6, INTERRUPT HANDLING, in Norm Cohen's book is
> dedicated to this very topic.
> 
> No, the OS doesn't make any difference.  The syntax for specifying an
> interrupt handler in Ada is the same for all platforms.
> 
> Basically, you declare a protected object, and use pragma Attach_Handler to
> designate a protected procedure as the interrupt handler.
> 
> See also pragma Interrupt_Handler and package Ada.Interrupts.

Have you actually tried this under Linux? There is no way this
will work. Unless you do lots of special things (see the documentation
of how to compile a Linux loadable kernel module), GNAT will produce
an ELF output file that can only be started as a normal user
process. And normal user processes CAN NOT handle interrupts
directly. The sections in the RM you quoted have been intended
for compilers for embedded systems, where the Ada runtime library
does everything that on a PC is done by the operating system or
where there is a special real-time operating system used.
All this does not apply for a compiler that produces normal
Unix application programms.

The Ada standard does not make it unnecessary that you get
familiar with the mechanisms of your operating system if you
want to access the hardware directly, including handling
interrupts! One of the main purpose of a time-sharing operating
system is to prevent you from directly accessing the hardware.

The GNAT RM says:

"C.3.1(20-21): Protected Procedure Handlers 

Whenever possible, the implementation should allow interrupt handlers to
be called directly by the hardware. Followed on any target where the
underlying operating system permits such direct calls."

Well, any Unix operating system I know is not a platform that
allows procedures in user processes to be called by hardware
interrupts. This has nothing to do with the programming language
used, this is an operating system issue.

Markus

-- 
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org,  home page: <http://www.cl.cam.ac.uk/~mgk25/>




  parent reply	other threads:[~1998-04-07  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-06  0:00 help about handling interrupts Igor Pascual Sagastagoitia
1998-04-06  0:00 ` Markus Kuhn
1998-04-07  0:00   ` Jerry van Dijk
1998-04-07  0:00   ` Samuel Tardieu
1998-04-07  0:00     ` Markus Kuhn
1998-04-07  0:00       ` Robert Dewar
1998-04-08  0:00         ` The pain with standards Markus Kuhn
1998-04-08  0:00         ` help about handling interrupts Dale Stanbrough
1998-04-07  0:00   ` Matthew Heaney
1998-04-07  0:00     ` Robert Dewar
1998-04-07  0:00       ` Matthew Heaney
1998-04-07  0:00     ` Markus Kuhn [this message]
     [not found]       ` <Er1oEK.IDB@world.std.com>
1998-04-07  0:00         ` Markus Kuhn
1998-04-07  0:00           ` Robert Dewar
replies disabled

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