Skip to content

Commit

Permalink
Merge pull request #191 from flaviojs/ensure-timeout-reached-cpu_idle…
Browse files Browse the repository at this point in the history
…_loop

Ensure the timeout time is reached in cpu_idle_loop.
  • Loading branch information
grossmj authored Mar 26, 2024
2 parents aa47776 + db1fc77 commit dab9a13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion stable/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ void cpu_idle_loop(cpu_gen_t *cpu)
pthread_mutex_lock(&cpu->idle_mutex);
t_spc.tv_sec = expire / 1000000;
t_spc.tv_nsec = (expire % 1000000) * 1000;
pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc);
while(pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc) != ETIMEDOUT) {
}
pthread_mutex_unlock(&cpu->idle_mutex);
}

Expand Down
3 changes: 2 additions & 1 deletion unstable/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ void cpu_idle_loop(cpu_gen_t *cpu)
pthread_mutex_lock(&cpu->idle_mutex);
t_spc.tv_sec = expire / 1000000;
t_spc.tv_nsec = (expire % 1000000) * 1000;
pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc);
while(pthread_cond_timedwait(&cpu->idle_cond,&cpu->idle_mutex,&t_spc) != ETIMEDOUT) {
}
pthread_mutex_unlock(&cpu->idle_mutex);
}

Expand Down

0 comments on commit dab9a13

Please sign in to comment.