History log of /haiku/src/system/kernel/posix/realtime_sem.cpp
Revision Date Author Comments
# a866e2d9 16-Feb-2022 Jérôme Duval <jerome.duval@gmail.com>

POSIX: introduce sem_clockwait

will appear in the next version: https://www.opengroup.org/austin/docs/austin_1110.pdf

Change-Id: Iee3faf23647aa5244ad316fe1c3d825592483935
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4966
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# c73d1301 08-Nov-2015 Michael Lotz <mmlr@mlotz.ch>

kernel: Use anonymous namespaces to avoid type collisions.

The anonymous namespace makes type definitions local to the translation
unit (like static does for objects). For pretty much any type not shared
across multiple files this is what one wants to happen (and might
erroneously expect to happen automatically).

This commit solves some actual collisions that were present:

* The VFS and the rootfs both used an incompatible VnodeHash struct for
their BOpenHashTable.
* XSI semaphores and message queues both used queued_thread, Ipc and
IpcHashTableDefinition.

For release builds these did not cause problems as the types were fully
inlined. Debug builds would crash at boot however because parts of a
BOpenHashTable<VnodeHash> from the rootfs meant to operate on struct
rootfs_vnode would be applied to one from the VFS expecting struct
vnode.

As such collisions are violations of the one definition rule, the code
is at fault and unfortunatley the compiler isn't required to diagnose
such problems across translation units (which isn't actually trivial).
This can lead to subtle and hard to debug problems and it's therefore
best to avoid leaking types into the global namespace whenever possible.


# d6d439f3 11-May-2015 Hamish Morrison <hamishm53@gmail.com>

Reimplement unnamed POSIX semaphores using user_mutex

* Fixes sharing semantics, so non-shared semaphores in non-shared
memory do not become shared after a fork.
* Adds two new system calls: _user_mutex_sem_acquire/release(),
which reuse the user_mutex address-hashed wait mechanism.
* Named semaphores continue to use traditional sem_id semaphores.


# 271ac910 09-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

Remove useless includes of khash.h

* These files were already converted to BOpenHashTable.
* For #9552.


# 73ad2473 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

Remove remaining unnecessary 'volatile' qualifiers


# c4a8ae38 07-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

realtime_sem: fixed a compiler warning.

* the variable is initialized anyway on the success code path.


# 4535495d 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5147963d 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6a6974b6 22-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

gcc 4 warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31192 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b668bf21 22-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Change function name to work with stricter name lookup in GCC 4.3. See
http://gcc.gnu.org/gcc-4.3/porting_to.html for reference.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28981 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 276aa463 24-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced the useless InitCheck() method in {Open,Multi}HashTable (it
always returned B_OK) by a Init() method, which sets the initial size
and returns an error, if that fails.
* Adjusted code using the classes accordingly. Replaced a few
InitCheck() methods in the network code by Init().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a636a339 10-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Use the new B_ABSOLUTE_REAL_TIME_TIMEOUT. Fixes pthread_cond_timedwait()
and pthread_mutex_timedlock() which were waiting system time relative
although their timeout parameter is Epoch relative.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3dfe682f 07-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added some padding to the sem_t structure.
* Changed the semantics of unnamed semaphores. Before parent and child
of a fork() would always share an earlier created semaphore. Now we do
that only, if the "shared" parameter of sem_init() was true. That's
still not quite the behavior Linux and Solaris have, but should be
perfectly fine with how reasonable code would use the API.
* There's a global table for shared unnamed semaphores now. ATM a
semaphore is leaked when no one explicitly destroys it (just as with
named sems).
* Enforce per-team and global semaphore number limits.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25362 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c00931f2 06-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Don't try to strdup() the name given for an unnamed semaphore.
* When initializing an unnamed semaphore failed, it would be deleted
twice.
* The user structure pointer wasn't correctly passed when initializing
named semaphores.
* When opening a named semaphore failed after it has already been
published, it is now unlinked again.
* The timeout passed to sem_timedwait() is relative to the Epoch. We
need to offset to system time.
* Added TODO regarding a per team semaphore limit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25345 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 98e67131 06-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved realtime_sem.{cpp,h} into new posix subdirectory.
* Renamed the old kernel_posix[_arch...].o to kernel_lib_posix...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25336 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d6d439f3f75a0986063d42eda8ff5281adcb29b1 11-May-2015 Hamish Morrison <hamishm53@gmail.com>

Reimplement unnamed POSIX semaphores using user_mutex

* Fixes sharing semantics, so non-shared semaphores in non-shared
memory do not become shared after a fork.
* Adds two new system calls: _user_mutex_sem_acquire/release(),
which reuse the user_mutex address-hashed wait mechanism.
* Named semaphores continue to use traditional sem_id semaphores.


# 271ac910a4cfdefa6393c1e7cb5e3a665404757d 09-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

Remove useless includes of khash.h

* These files were already converted to BOpenHashTable.
* For #9552.


# 73ad2473e7874b3702cf5b0fdf4c81b747812ed9 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

Remove remaining unnecessary 'volatile' qualifiers


# c4a8ae38d42ee72a6cbde2fd428d1638d5269506 07-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

realtime_sem: fixed a compiler warning.

* the variable is initialized anyway on the success code path.


# 4535495d80c86e19e2610e7444a4fcefe3e0f8e6 10-Jan-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged the signals branch into trunk, with these changes:
* The team and thread kernel structures have been renamed to Team and Thread
respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5147963dcd57fefa4f63c484eb88e9eaf4002976 26-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than
Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6a6974b63eb062d0f301c57d44703389f823654c 22-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

gcc 4 warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31192 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b668bf21b2bc935a7f05a1c97220ae2bb5eea024 22-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Change function name to work with stricter name lookup in GCC 4.3. See
http://gcc.gnu.org/gcc-4.3/porting_to.html for reference.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28981 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 276aa463efb0cc5b6562c46b540c01df679f77ba 24-Jun-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced the useless InitCheck() method in {Open,Multi}HashTable (it
always returned B_OK) by a Init() method, which sets the initial size
and returns an error, if that fails.
* Adjusted code using the classes accordingly. Replaced a few
InitCheck() methods in the network code by Init().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26127 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a636a33926ec5b330d09ae0cfa0c60363450f2f7 10-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Use the new B_ABSOLUTE_REAL_TIME_TIMEOUT. Fixes pthread_cond_timedwait()
and pthread_mutex_timedlock() which were waiting system time relative
although their timeout parameter is Epoch relative.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25435 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3dfe682f55250bfe5309902ec217fea71b50c7bb 07-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added some padding to the sem_t structure.
* Changed the semantics of unnamed semaphores. Before parent and child
of a fork() would always share an earlier created semaphore. Now we do
that only, if the "shared" parameter of sem_init() was true. That's
still not quite the behavior Linux and Solaris have, but should be
perfectly fine with how reasonable code would use the API.
* There's a global table for shared unnamed semaphores now. ATM a
semaphore is leaked when no one explicitly destroys it (just as with
named sems).
* Enforce per-team and global semaphore number limits.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25362 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c00931f204af4e4772872b987da2356776ff22e5 06-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Don't try to strdup() the name given for an unnamed semaphore.
* When initializing an unnamed semaphore failed, it would be deleted
twice.
* The user structure pointer wasn't correctly passed when initializing
named semaphores.
* When opening a named semaphore failed after it has already been
published, it is now unlinked again.
* The timeout passed to sem_timedwait() is relative to the Epoch. We
need to offset to system time.
* Added TODO regarding a per team semaphore limit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25345 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 98e67131727de15752bc87a530612040c6955d17 06-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved realtime_sem.{cpp,h} into new posix subdirectory.
* Renamed the old kernel_posix[_arch...].o to kernel_lib_posix...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25336 a95241bf-73f2-0310-859d-f6bbb57e9c96