For example, functions like futex_wake/futex_wait, epoll_ctl/epoll_wait, pthread_create provide acquire/release semantics. That's to say, I made some changes before calling futex_wake, and then the woken thread always sees the changes.
My question is
- does the read/write to
eventfdoffer acquire/release semantics? - is there any documents about this? I have checked the man page and did not find the answer about 1.
see blow code as an example:
initial:
int g_atomic_val = 0;
int evfd = eventfd();
int64_t w_cnt = 1, r_cnt;
thread1:
/* set some data, then write eventfd */
g_atomic_val = 1;
write(evfd, &w_cnt, sizeof(w_cnt));
thread2:
for (;;) {
/* polling event fd */
poll(evfd);
read(evfd, &r_cnt, sizeof(r_cnt));
/* Does g_atomic_val always equals to 1? */
assert(g_atomic_val == 1);
}