Only when using multithreading (as of in High Performance Mode) nanosleep() at vos_threadDelay() can all the time get interrupted and thus leaving the program stuck in an unexpected infinite loop.
This problem occurs in an environment with many interruptions. If an interruption ocurrs during the call of nanosleep(), in theory the nanosleep() function is called again with the updated time (the original time minus the time expired in the previous call) but what happens is that it remains blocked indefinitely.
Taking a look at the man page of the nanosleep function, in relation to this problem it says the following: "The fact that nanosleep() sleeps for a relative interval can be problematic if the call is repeatedly restarted after being interrupted by signals, since the time between the interruptions and restarts of the call will lead to drift in the time when the sleep finally completes. This problem can be avoided by using clock_nanosleep(2) with an absolute time value."
In conclusion, replacing the nanosleep () function with clock_nanosleep () fixes the problem.
I attach the file "src/vos/posix/vos_thread.c" (versión 2.0.2.0 of the trdp library) with the solution.
The original file (src/vos/posix/vos_thread.c)
Hi Gari,
thanx a lot. I'll incorporate your changes asap.
/Bernd
@Gari: Can you verify the current implementation (trunk)?
@bloehr: We try to integrate the trunk implementation in our code to check it but we get some compilation errors related to the differences between both codes and we can´t verify it. However, the patch has been applied just as we reported, so it looks like it will work fine.
This most probably because of some minor API changes in 2.1 because of the conformance testing.
Which OS is your target: Linux or Integrity?
Hi Bernd!
@bloehr: It's Linux.
changed, tested by inspection