You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
322 B
20 lines
322 B
#include <stdio.h>
|
|
#include <stdatomic.h>
|
|
|
|
atomic_int acnt = 0;
|
|
atomic_int bcnt = 0;
|
|
|
|
int foo() {
|
|
for(int n = 0; n < 1000; ++n) {
|
|
++acnt;
|
|
if(acnt % 10 == 0)
|
|
++bcnt;
|
|
}
|
|
return acnt;
|
|
}
|
|
|
|
int main(void) {
|
|
int acnt = foo();
|
|
printf("First atomic counter is %u, second is %u\n", acnt, bcnt);
|
|
return 0;
|
|
}
|
|
|