Many thanks for your answers!
1. No, I do not open and close the file when I have to write something in the csv file. I open the file when it is created and I close the file when the program is finished.
2. I have made a lot of different test with different operating system (jessie and wheezy), Raspberry Pi 2 and Model B+, different SD cards and what I have discovered is that the culprit is the Wheezy operating system or the SD cards that have Wheezy installed. I can run the program with Model B+ and Jessie SD card and in despite of not being as fast as when I run in RPi 2, the csv writing interrupts do not appear... The best performance I get with RPi 2 and Jessie, and if I run using multi threading code, the performance is even better.
Trying with RPI 2 and Wheezy, the writing delays continue appearing...
3. Despite the fact that I know the culprit of the problem and I know how to solve it, I am really interested in know more about chrt and nice commands. I can run using nice command but I do not know how to apply chrt command, to set my program with Real Time priority and I think this could be improve a little bit more the performance.