ISR and a normal function

V

vhanwaribrahim

Hi all,

Can any one tell the actual differences between a software ISR in C
and a normal C function?
What are the things to be taken care when writing an ISR in C?
I have an embedded hardware with l2/l3 switching logic. I want to
register for an interrupt with the hardware and i want an ISR in C to
get executed for that interrupt.

With Regards
Anwar
 
J

Jim Langston

Hi all,

Can any one tell the actual differences between a software ISR in C
and a normal C function?
What are the things to be taken care when writing an ISR in C?
I have an embedded hardware with l2/l3 switching logic. I want to
register for an interrupt with the hardware and i want an ISR in C to
get executed for that interrupt.

ISR? Do you mean a TSR? I haven't heard of an ISR.
 
J

James Beck

I presume ISR = Interrupt Service Routine.
Yep, and I'm pretty sure any support for hardware and software
interrupts are a compiler specific extension and not standard C.

Jim
 
V

vippstar

Yep, and I'm pretty sure any support for hardware and software
interrupts are a compiler specific extension and not standard C.
Well, signals are interrupts aren't they? Standard C has <signal.h>.
 
J

James Beck

Well, signals are interrupts aren't they? Standard C has <signal.h>.
Can you use that to handle a UART interrupt?
From what I see SIGXXXX is pretty OS specific, ANSI or not.
SIGINT in MS-DOS is int0x23, program termination. Not very useful for
anything other than executing some custom shutdown/exit routine.

Jim
 
R

Richard Tobin

Yep, and I'm pretty sure any support for hardware and software
interrupts are a compiler specific extension and not standard C.
[/QUOTE]
Well, signals are interrupts aren't they?

True in a sense, but probably not relevant to the OP's situation.

C's and Unix's signals are an abstraction of hardware interrupts.
When, say, a segmentation violation happens the processor gets an
interrupt, which is handled by the kernel. That handling may involve
calling a signal handler in the affected C program. But there is no
necessary relation between the calling convention used by the hardware
interrupt and that used by the resulting C signal. The call to the
signal handler is just like any other function call - or at least,
sufficiently like it that the signal handler can be used a a normal C
function, while the call to the interrupt handler probably uses a
quite different convention, probably a very minimal one that requires
the called function to save registers and so on.

-- Richard
 
V

vhanwaribrahim

True in a sense, but probably not relevant to the OP's situation.

C's and Unix's signals are an abstraction of hardware interrupts.
When, say, a segmentation violation happens the processor gets an
interrupt, which is handled by the kernel.  That handling may involve
calling a signal handler in the affected C program.  But there is no
necessary relation between the calling convention used by the hardware
interrupt and that used by the resulting C signal.  The call to the
signal handler is just like any other function call - or at least,
sufficiently like it that the signal handler can be used a a normal C
function, while the call to the interrupt handler probably uses a
quite different convention, probably a very minimal one that requires
the called function to save registers and so on.

-- Richard

Hi Richard,
I have heard that when you are writing an interrrupt service routine
(ISR), it should not
use semaphores or mutexes and not to use printfs inside ISR.
Whats the exact reason behind this?

With Regards
Anwar
 
R

Richard Tobin

I have heard that when you are writing an interrrupt service routine
(ISR), it should not
use semaphores or mutexes and not to use printfs inside ISR.
Whats the exact reason behind this?

Obviously you don't want an interrupt handler to block the operating
system from doing other things for more than a few nanoseconds, but
exactly what that implies depends on your system.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top