aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2014-10-24 20:02:44 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2014-10-24 20:02:44 +0000
commit53e1ffbbce9f27355c117f7d8c5a02ad85770800 (patch)
treeff024ddfa290c34065e439d40ebeac2d43870f71 /include
parent7d313e7bdbe5f1f06efc670847802b45b15efb71 (diff)
downloadsrc-53e1ffbbce9f27355c117f7d8c5a02ad85770800.tar.gz
src-53e1ffbbce9f27355c117f7d8c5a02ad85770800.zip
The current POSIX semaphore implementation stores the _has_waiters flag
in a separate word from the _count. This does not permit both items to be updated atomically in a portable manner. As a result, sem_post() must always perform a system call to safely clear _has_waiters. This change removes the _has_waiters field and instead uses the high bit of _count as the _has_waiters flag. A new umtx object type (_usem2) and two new umtx operations are added (SEM_WAIT2 and SEM_WAKE2) to implement these semantics. The older operations are still supported under the COMPAT_FREEBSD9/10 options. The POSIX semaphore API in libc has been updated to use the new implementation. Note that the new implementation is not compatible with the previous implementation. However, this only affects static binaries (which cannot be helped by symbol versioning). Binaries using a dynamic libc will continue to work fine. SEM_MAGIC has been bumped so that mismatched binaries will error rather than corrupting a shared semaphore. In addition, a padding field has been added to sem_t so that it remains the same size. Differential Revision: https://reviews.freebsd.org/D961 Reported by: adrian Reviewed by: kib, jilles (earlier version) Sponsored by: Norse
Notes
Notes: svn path=/head/; revision=273604
Diffstat (limited to 'include')
-rw-r--r--include/semaphore.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/semaphore.h b/include/semaphore.h
index 3531353d0d3a..218de995392e 100644
--- a/include/semaphore.h
+++ b/include/semaphore.h
@@ -38,7 +38,8 @@
struct _sem {
__uint32_t _magic;
- struct _usem _kern;
+ struct _usem2 _kern;
+ __uint32_t _padding; /* Preserve structure size */
};
typedef struct _sem sem_t;