projects
/
model-checker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
README.md: add extra blank lines
[model-checker.git]
/
test
/
userprog.c
diff --git
a/test/userprog.c
b/test/userprog.c
index 6ad49092d7e1073ebe40bd8a868049847adc78f8..02a83b4b2f2469f6af1f59c77038ed95c7878998 100644
(file)
--- a/
test/userprog.c
+++ b/
test/userprog.c
@@
-1,8
+1,8
@@
#include <stdio.h>
#include <stdio.h>
-
#include <threads.h>
#include <threads.h>
+#include <stdatomic.h>
+
#include "librace.h"
#include "librace.h"
-#include "stdatomic.h"
atomic_int x;
atomic_int y;
atomic_int x;
atomic_int y;
@@
-11,14
+11,14
@@
static void a(void *obj)
{
int r1=atomic_load_explicit(&y, memory_order_relaxed);
atomic_store_explicit(&x, r1, memory_order_relaxed);
{
int r1=atomic_load_explicit(&y, memory_order_relaxed);
atomic_store_explicit(&x, r1, memory_order_relaxed);
- printf("r1=%
u
\n",r1);
+ printf("r1=%
d
\n",r1);
}
static void b(void *obj)
{
int r2=atomic_load_explicit(&x, memory_order_relaxed);
atomic_store_explicit(&y, 42, memory_order_relaxed);
}
static void b(void *obj)
{
int r2=atomic_load_explicit(&x, memory_order_relaxed);
atomic_store_explicit(&y, 42, memory_order_relaxed);
- printf("r2=%
u
\n",r2);
+ printf("r2=%
d
\n",r2);
}
int user_main(int argc, char **argv)
}
int user_main(int argc, char **argv)
@@
-28,13
+28,13
@@
int user_main(int argc, char **argv)
atomic_init(&x, 0);
atomic_init(&y, 0);
atomic_init(&x, 0);
atomic_init(&y, 0);
- printf("
Thread %d: creating 2 threads\n", thrd_current()
);
+ printf("
Main thread: creating 2 threads\n"
);
thrd_create(&t1, (thrd_start_t)&a, NULL);
thrd_create(&t2, (thrd_start_t)&b, NULL);
thrd_join(t1);
thrd_join(t2);
thrd_create(&t1, (thrd_start_t)&a, NULL);
thrd_create(&t2, (thrd_start_t)&b, NULL);
thrd_join(t1);
thrd_join(t2);
- printf("
Thread %d is finished\n", thrd_current()
);
+ printf("
Main thread is finished\n"
);
return 0;
}
return 0;
}