Hello,
When I do mmap(MAP_ANONYMOUS | MAP_SHARED) and then fork(), it seems
that futex(2) wakeups are not delivered between child and parent in
that memory. It does work as expected if I instead use
shmget(IPC_PRIVATE).
Below is a standalone test program. I tested it with the four OSes
mentioned, and the two shmem types depending on that #if, and all
worked as expected except the OpenBSD/mmap case, which hangs.
Is it a bug?
$ uname -a
OpenBSD openbsd6.localdomain 6.9 GENERIC.MP#473 amd64
Thanks,
=== 8< ===
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/ipc.h>
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#if defined(__linux__)
#include <linux/futex.h>
#include <sys/syscall.h>
#elif defined(__OpenBSD__)
#include <sys/time.h>
#include <sys/futex.h>
#elif defined(__FreeBSD__)
#include <sys/types.h>
#include <sys/umtx.h>
#elif defined(__APPLE__)
#define UL_COMPARE_AND_WAIT_SHARED 3
#define ULF_WAKE_ALL 0x00000100
extern int __ulock_wait(uint32_t operation, void *addr, uint64_t
value, uint32_t timeout);
extern int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value);
No comments:
Post a Comment