printf in interrupt handlers

Jiri Gaisler jiri at
Thu Jan 20 11:09:42 UTC 2005

Simple question: is printf in interrupt handlers allowed?

It is not that I really want to do a printf in an interrupt
handler, but when I tried it, RTEMS halts with
Internal_error_Occurred(). This behaviour started on rtems-4.6,
the earlier rtmes-4.5 could do a printf from an interrupt
handler without problems. I am trying this on the SPARC
(ERC32/LEON) target. The back trace after the error is:

     %pc          %sp
#0   0x40002d7c   0x403ff350   _Internal_error_Occurred + 0x40
#1   0x40007120   0x403ff3b8   rtems_semaphore_obtain + 0x11c
#2   0x400083b4   0x403ff428   rtems_termios_write + 0x18
#3   0x400032a8   0x403ff490   rtems_io_write + 0x4c
#4   0x400113d8   0x403ff4f8   device_write + 0x30
#5   0x4001ba34   0x403ff578   write + 0x90
#6   0x40012d74   0x403ff5e0   fflush + 0x8c
#7   0x40018068   0x403ff648   __sfvwrite + 0x350
#8   0x40014ba0   0x403ff6b0   _vfiprintf_r + 0xe7c
#9   0x400163c8   0x403ff718   _vfprintf_r + 0x16f8
#10  0x40013354   0x403ff9a0   printf + 0x2c
#11  0x4000285c   0x403ffa08   _ISR_Handler + 0x130
#12  0x40001228   0x403f8818   Init + 0x2c
#13  0x400129f0   0x403f8938   _Thread_Handler + 0x110
#14  0x400128d8   0x403f89a0   memfile_check_rmnod + 0x70

A bit debugging shows that rtems_semaphore_obtain() fails for
some reason and Internal_error_Occurred is called. It does not
seem to be a stack problem - I have increased the interrupt stack
to 256 kbyte as a test.

Jiri Gaisler.

Gaisler Research, 1:a Långgatan 19, 413 27 Goteborg, Sweden, +46-317758650
fax: +46-31421407 email: info at, home page:

More information about the users mailing list