Printing in ISR

[size=150]If i cannot use printf in ISR, then what function can i use instead to print something to my console[/size]

If you mean what can you use to print from an ISR, I don’t think that QNX 6 provides such a function. QNX 2 had such a function, and I think QNX 4 might have. If you have such a need there are two ways you might achieve this.

  1. Have a buffer area that is accessable from the isr and a printing thread. The ISR puts a message in the buffer and turns on a dirty byte. The printing thread prints the message and turns off the byte. You could get quite elaborate here with a ringed chain of messages.

  2. Figure out where the video memory mapped buffer is, and write to it directly.

I might add, I really hope you are only planning to do this for diagnostic purposes. Assuming that you are writing a driver, you might well finesse the problem by having the interrupt wake up a thread, and run the hardware code in the thread, making printf available. You can build the driver this way in two stages. First debug the hardware issues, and then put the interrupt code back into the ISR.

Use InterruptAttachEvent that way your ISR can use any functions. By they way doing a printf in a ISR is a very bad idea, even if it’s for debugging.

Doing a printf in an ISR is worse than a very bad idea, it won’t work and if it doesn’t crash the OS, you were just darn lucky. Copying a debug message to memory mapped ram isn’t all that good an idea either given that using Mario’s InterruptAttachEvent and putting a printf in the thread context will work so much better. Better yet, leave the code in the thread context if it will work. But it is always possible that this type of debugging could mask a bug you are looking for. This was much more common with slower processors, and I haven’t run into a problem like this in QNX 6 before.