Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect predictions if code contains usleep calls #231

Open
mbUSC opened this issue Apr 30, 2024 · 0 comments
Open

Incorrect predictions if code contains usleep calls #231

mbUSC opened this issue Apr 30, 2024 · 0 comments

Comments

@mbUSC
Copy link

mbUSC commented Apr 30, 2024

How to reproduce the problem

1. #define _GNU_SOURCE 1
2. 
3. #include <stdio.h>
4. #include <pthread.h>
5. #include <unistd.h>
6. #include <coz.h>
7. 
8. static const unsigned int NUM_ITERATIONS = 100000;
9. 
10. void* threadA_fn(void* barrier) {
11.     for (int i = 0; i < NUM_ITERATIONS; i++) {
12.         usleep(2500);
13.         pthread_barrier_wait(barrier);
14.         COZ_PROGRESS;
15.     }
16. }
17. 
18. void* threadB_fn(void* barrier) {
19.     for (int i = 0; i < NUM_ITERATIONS; i++) {
20.         usleep(10000);
21.         pthread_barrier_wait(barrier);
22.         COZ_PROGRESS;
23.     }
24. }
25. 
26. int main(void) {
27.     pthread_t threadA;
28.     pthread_t threadB;
29.     pthread_barrier_t barrier;
30. 
31.     pthread_barrier_init(&barrier, NULL, 2);
32. 
33.     pthread_create(&threadA, NULL, threadA_fn, &barrier);
34.     pthread_create(&threadB, NULL, threadB_fn, &barrier);
35. 
36.     pthread_join(threadA, NULL);
37.     pthread_join(threadB, NULL);
38. 
39.     pthread_barrier_destroy(&barrier);
40. }

Environment

Processor: 12th Gen Intel(R) Core(TM) i7-12800H 2.40 GHz
Installed RAM: 32.0 GB (31.6 GB usable)
OS: Windows 11 (WSL)

Results from Coz

screenshot (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant