TIMER: Add abort logic if sim_idle_ms_sleep() sleeps for 0 with an error
As discussed in #594
This commit is contained in:
parent
076af54ad3
commit
9b95115a2a
1 changed files with 9 additions and 2 deletions
|
@ -239,6 +239,7 @@ uint32 sim_idle_ms_sleep (unsigned int msec)
|
||||||
uint32 start_time = sim_os_msec();
|
uint32 start_time = sim_os_msec();
|
||||||
struct timespec done_time;
|
struct timespec done_time;
|
||||||
t_bool timedout = FALSE;
|
t_bool timedout = FALSE;
|
||||||
|
int stat;
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &done_time);
|
clock_gettime(CLOCK_REALTIME, &done_time);
|
||||||
done_time.tv_sec += (msec/1000);
|
done_time.tv_sec += (msec/1000);
|
||||||
|
@ -249,10 +250,16 @@ if (done_time.tv_nsec > 1000000000) {
|
||||||
}
|
}
|
||||||
pthread_mutex_lock (&sim_asynch_lock);
|
pthread_mutex_lock (&sim_asynch_lock);
|
||||||
sim_idle_wait = TRUE;
|
sim_idle_wait = TRUE;
|
||||||
if (!pthread_cond_timedwait (&sim_asynch_wake, &sim_asynch_lock, &done_time))
|
stat = pthread_cond_timedwait (&sim_asynch_wake, &sim_asynch_lock, &done_time);
|
||||||
|
if (stat == 0)
|
||||||
sim_asynch_check = 0; /* force check of asynch queue now */
|
sim_asynch_check = 0; /* force check of asynch queue now */
|
||||||
else
|
else
|
||||||
|
if (stat == ETIMEDOUT)
|
||||||
timedout = TRUE;
|
timedout = TRUE;
|
||||||
|
else {
|
||||||
|
fprintf (stderr, "sim_idle_ms_sleep(%u): pthread_cond_timedwait() return %d - %s\n", msec, stat, strerror (stat));
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
sim_idle_wait = FALSE;
|
sim_idle_wait = FALSE;
|
||||||
pthread_mutex_unlock (&sim_asynch_lock);
|
pthread_mutex_unlock (&sim_asynch_lock);
|
||||||
if (!timedout) {
|
if (!timedout) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue