mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-01 10:12:27 +00:00
Improve multithreading
This commit is contained in:
parent
d3167126aa
commit
30afd6ddbb
38 changed files with 752 additions and 174 deletions
|
@ -50,12 +50,10 @@ TEST(cosmo_once, test) {
|
|||
pthread_t th[N];
|
||||
x = y = 0;
|
||||
ASSERT_EQ(0, pthread_barrier_init(&b, 0, N));
|
||||
for (i = 0; i < N; ++i) {
|
||||
for (i = 0; i < N; ++i)
|
||||
ASSERT_EQ(0, pthread_create(th + i, 0, Worker, 0));
|
||||
}
|
||||
for (i = 0; i < N; ++i) {
|
||||
for (i = 0; i < N; ++i)
|
||||
ASSERT_EQ(0, pthread_join(th[i], 0));
|
||||
}
|
||||
ASSERT_EQ(N, atomic_load(&x));
|
||||
ASSERT_EQ(1, atomic_load(&y));
|
||||
ASSERT_EQ(0, pthread_barrier_destroy(&b));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue