Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Printf stop to work only into one task

Hello,

I have a problem with printf function. I have seen the other post about it but I am not sure it's the same issue.

I have a board with a stratix and so nios II. The software has multiple tasks whose one of them is dedicated to monitoring by reading lot of registers and printing their value. We have several hardware designs and the software is ok for all except one. So the problem is probably hardware but what could be the problem's cause ?

So the problem is that at a moment, the monitoring task stop to print the register values. The task continues to be executed since other actions as incrementing a counter are done (this counter is used for pio led). Printf are also ok for all other tasks.

The stdout use uart link to send it to another board. I am not sure but it seems that not reading registers prevents from printf crash into this task. If it's the cause what is the relation between reading registers and using printf.

Thanks

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    IIRC the UART input/output functions aren't thread safe. If you have several tasks that attempt to write to the JTAG uart at the same time you can have a crash. It's better to either use a mutex when writing to prevent several tasks from doing it at the same time, or do all the printing from a single task.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Ok thanks I will try but I couldn't give you the result quickly since I have no more hardware to test.