History log of /haiku/src/system/kernel/posix/xsi_message_queue.cpp
Revision Date Author Comments
# 959d9cd0 21-Sep-2023 Augustin Cavalier <waddlesplash@gmail.com>

kernel: Cleanups to the XSI message queue & semaphore implementations.

* Remove unused/unneeded parameters to Dequeue.
* Make use of StackOrHeapArray.
* Reorder syscall-entry checks for efficiency.
* Inline the unlock-block method and unset variables in the process.
* Reorder code for clarity and to reduce indentation.


# 8540053c 26-Apr-2023 Augustin Cavalier <waddlesplash@gmail.com>

xsi_message_queue & xsi_semaphore: Downgrade a lot of traces.

Reduces syslog spam.


# d8f78afc 26-Apr-2023 Augustin Cavalier <waddlesplash@gmail.com>

xsi_message_queue: Permit incoming buffer to be NULL.

The user address space has not included NULL for a while, so this
has actually been broken for years, and nobody noticed. I guess
XSI message queues are not very well used?

Fixes the in-tree "xsi_msg_queue_test1".


# 6acd708e 26-Apr-2023 Augustin Cavalier <waddlesplash@gmail.com>

xsi_message_queue & xsi_semaphore: Use condition variables to wait.

This removes a lot of custom logic for managing waiting threads,
which was not even correct in all cases (and the code actually
acknowledged this with a big TODO about it, which weinhold
added all the way back in 2008!)


# bddb122e 18-Jan-2021 Jérôme Duval <jerome.duval@gmail.com>

kernel/xsi_msg: if MessageQueueID() is -1, the message queue doesn't exist

fix #16757

Change-Id: I7c381e18c468b8c209fb275ef5e899c49aa26ffd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3643
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 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.


# 20ded5c2 06-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel/posix: Do not use thread_block_locked()


# 077c84eb 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# c8dd9f77 29-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Add thread_unblock() and use it where possible


# 4be4fc6b 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# d9a215b7 26-Nov-2011 Philippe Saint-Pierre <stpere@gmail.com>

Comparison with an unsigned value (size_t) and < 0

CID 4190 and CID 4191


# 24df6592 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


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


# 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


# e360230e 25-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

_user_xsi_msgrcv():
* Fixed some places that set an error return value but didn't actually
return.
* Fixed success case return value. The number of bytes received must be
returned, not B_OK.


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


# 8a05bb86 16-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added TODO regarding serious locking problem.


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


# b9b04b6c 11-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* If the receving buffer if bigger than the message, truncate the length copied
to the one of the message
* Fix comparison
* Clean up


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


# 7adf6ce1 10-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Set msg_qbytes on IPC_SET
* Wake up only one thread waiting to send.


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


# 3b1f1178 09-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Wake up waiting threads when a new message is sent or received
* Removed sXsiMessageCountLock in favor of atomic_* function utility
* free up any remaining messages when a queue gets destroyed


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


# b6cd7771 04-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Fix cast in user_memcpy
* Fix comparison

send and receive simple message seems to work now.


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


# d9bf7154 04-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented msgrcv and msgsnd. Not complete yet.
* Reworked the way IDs are geneterad in the same way they are in xsi semaphores


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


# 25d466ba 03-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Start implementing _kern_xsi_msgsnd().


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


# 842f1dfa 01-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Start implementing _kern_msgctl() syscall



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


# 6d3973a5 31-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Removed unecessary HasMessageQueue method


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


# 9309ec86 31-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

Start implementing POSIX message queue IPC
* Implemented _kern_msgget()

Work in progress, some stuff may be removed.



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


# 20ded5c2eb7b51da4e34c40078de2903243ef56f 06-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel/posix: Do not use thread_block_locked()


# 077c84eb27b25430428d356f3d13afabc0cc0d13 05-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: atomic_*() functions rework

* No need for the atomically changed variables to be declared as
volatile.
* Drop support for atomically getting and setting unaligned data.
* Introduce atomic_get_and_set[64]() which works the same as
atomic_set[64]() used to. atomic_set[64]() does not return the
previous value anymore.


# c8dd9f7780c426e592a3ccb231e6bfab51f15eb9 29-Oct-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Add thread_unblock() and use it where possible


# 4be4fc6b1faddbd037146214a0011d320842b4f3 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# d9a215b71f75394472023d63b60318332e6e0d45 26-Nov-2011 Philippe Saint-Pierre <stpere@gmail.com>

Comparison with an unsigned value (size_t) and < 0

CID 4190 and CID 4191


# 24df65921befcd0ad0c5c7866118f922da61cb96 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


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


# 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


# e360230ecdc236e9bc17e790bf0f689566f688c0 25-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

_user_xsi_msgrcv():
* Fixed some places that set an error return value but didn't actually
return.
* Fixed success case return value. The number of bytes received must be
returned, not B_OK.


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


# 8a05bb865f8402bd40875b2f477f122f38094309 16-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added TODO regarding serious locking problem.


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


# b9b04b6c327f7d8b5dc5bcc58ae1ed74145d28cc 11-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* If the receving buffer if bigger than the message, truncate the length copied
to the one of the message
* Fix comparison
* Clean up


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


# 7adf6ce100390e47ad2e151ccd0d4d159807467e 10-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Set msg_qbytes on IPC_SET
* Wake up only one thread waiting to send.


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


# 3b1f1178aaffe1cfdde8b6e1200b8df0c29a13ab 09-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Wake up waiting threads when a new message is sent or received
* Removed sXsiMessageCountLock in favor of atomic_* function utility
* free up any remaining messages when a queue gets destroyed


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


# b6cd7771e7b8b0ae96ad39ebe8b0a99fa10af56d 04-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Fix cast in user_memcpy
* Fix comparison

send and receive simple message seems to work now.


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


# d9bf7154952fc346a4f7df348a8c8240239cf99f 04-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Implemented msgrcv and msgsnd. Not complete yet.
* Reworked the way IDs are geneterad in the same way they are in xsi semaphores


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


# 25d466ba72dd6be8e5b7d9baa72bc87360c4175f 03-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Start implementing _kern_xsi_msgsnd().


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


# 842f1dfab521050bd0ac95c42c89d7e435395b89 01-Sep-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Start implementing _kern_msgctl() syscall



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


# 6d3973a54a8d1e438c7c60f3dc3e2783704f958c 31-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Removed unecessary HasMessageQueue method


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


# 9309ec863555b344d9ca0aae1369b8562522722b 31-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

Start implementing POSIX message queue IPC
* Implemented _kern_msgget()

Work in progress, some stuff may be removed.



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