History log of /haiku/headers/private/kernel/util/AutoLock.h
Revision Date Author Comments
# 057fe191 01-Sep-2021 Augustin Cavalier <waddlesplash@gmail.com>

kernel: Break thread-related AutoLockers into a separate header.

Including thread.h brings a massive array of things with it from
the kernel thread arch headers, team and thread definitions,
hash tables, linked lists, Referenceable, etc. that the vast majority
of AutoLock.h consumers neither want nor need.

So, put these in a separate header, and adjust all consumers of these
lockers to include the new file.

This change exposes the fact that a lot of files were inadvertently
making use of headers included indirectly through thread.h. Those
will be fixed in the next commit.


# 94887feb 20-Jul-2015 Jérôme Duval <jerome.duval@gmail.com>

Added some support for GCC 5+.


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

kernel: Add read write spinlock implementation


# 4824f763 04-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Add sequential lock implementation


# 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


# 8de72f9d 01-Dec-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup.


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


# 91393e78 22-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

InterruptsSpinLocking:
* Removed unused inner struct State.
* Added work-around for the extremely annoying "fState my be used
uninitialized" warning gcc 4 produces. I'm not aware of any solution that
doesn't generate unnecessary code. :-/


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


# 3b248948 16-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added ThreadCPUPinner AutoLocker class.


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


# 06d5e1b3 07-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Added ReadLocker/WriteLocker classes to auto lock an rw_lock.
* Added *_init_etc() functions to the fs_shell.


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


# 2b07b8e0 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


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


# 0c615a01 01-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed old mutex implementation and renamed cutex to mutex.
* Trivial adjustments of code using mutexes. Mostly removing the
mutex_init() return value check.
* Added mutex_lock_threads_locked(), which is called with the threads
spinlock being held. The spinlock is released while waiting, of
course. This function is useful in cases where the existence of the
mutex object is ensured by holding the threads spinlock.
* Changed the two instances in the VFS code where an IO context of
another team needs to be locked to use mutex_lock_threads_locked().
Before it required a semaphore-based mutex implementation.


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


# 8562499f 30-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced a new locking primitive I called "cutex" (sorry for the
name, couldn't resist :-P). It's semantically equivalent to a mutex,
but doesn't need a semaphore (it uses thread blocking and a simple
queue instead). Initialization can't fail. In fact it is ready to use
without initialization when living in the bss segment, also in the
early boot process. It's as fast as a benaphore in cases of low lock
contention, and faster otherwise. Only disadvantage is the higher
immediate memory footprint of 16 bytes.
* Changed how the "thread" and "threads" debugger commands list the
objects they are waiting for. Cutexes are also included.


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


# be899011 27-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Base class of InterruptsLocker was accidentially private.
* Added class InterruptsSpinLocker, which disables interrupts and
acquires a spinlock all in one.


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


# bce7e9f6 09-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added AutoLocker instantiations IterruptsLocker (disables/restores
interrupts) and SpinLocker (acquires/releases spinlocks).
* Adjusted Jamfiles of components that used <util/AutoLock.h> but didn't
add all header directories required now (<int.h> was added).



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


# 2b2ec438 26-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the AutoLocker class out of the kernel/utils/AutoLock.h header
into its own shared/AutoLocker.h. It can be used by userland code too.
* Removed headers/private/shared/ObjectLocker.h and replaced all uses of
BObjectLocker by AutoLocker.


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


# 27810ccf 22-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added the last useful features I dare imagine: A Lock() method and the
possibility to initialize the AutoLocker without locking the object even
if it is unlocked yet. Especially in loops Lock()/Unlock() come handy
when an otherwise constantly hold lock needs to be unlocked for a short
time.

I suppose we should move the kernel utils AutoLocker implementation
to headers/private/shared, and drop the less powerful ObjectLocker.


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


# aa547f5f 07-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

* mutex_lock() and recursive_lock_lock() now return a status_t and report failure.
* recursive_lock_unlock() now returns a void to mirror it's counterpart better;
use recursive_lock_get_recursion() if you're interested in the lock depth.
* switch_sem(), and release_sem() now don't do anything anymore in kernel startup
mode.


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


# 3e15f83d 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Added a BenaphoreLocker.


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


# 8af41139 20-Mar-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Added default constructor. Useful in combination with SetTo().

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


# b6933d8a 30-Jan-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved generic auto locking code out of
<disk_device_manager/KDiskDeviceUtils.h> into <util/AutoLock.h>.
Added instantiations for recursive locks (moved from vfs.cpp) and
mutexes.


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


# 94887feb6442669d41c72e998a0a4e57fee8cba1 20-Jul-2015 Jérôme Duval <jerome.duval@gmail.com>

Added some support for GCC 5+.


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

kernel: Add read write spinlock implementation


# 4824f7630b2ca9c5750f93c4daa837dfcac3059e 04-Nov-2013 Pawel Dziepak <pdziepak@quarnos.org>

kernel: Add sequential lock implementation


# 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


# 8de72f9d586809e8fe1040fc458b19422b79026e 01-Dec-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup.


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


# 91393e78100e38eafdf3e6044741b6ee79cf4d00 22-Jun-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

InterruptsSpinLocking:
* Removed unused inner struct State.
* Added work-around for the extremely annoying "fState my be used
uninitialized" warning gcc 4 produces. I'm not aware of any solution that
doesn't generate unnecessary code. :-/


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


# 3b248948f21687069bab85d82048ea59403bc8ad 16-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added ThreadCPUPinner AutoLocker class.


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


# 06d5e1b3b65bfdfad8cf2642956e63c38fc79542 07-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Added ReadLocker/WriteLocker classes to auto lock an rw_lock.
* Added *_init_etc() functions to the fs_shell.


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


# 2b07b8e0f1a7f1e76f31db24a21a42cbb01d7b9c 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


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


# 0c615a01ae49634aaf59fbe35b3d55b3bb8890df 01-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed old mutex implementation and renamed cutex to mutex.
* Trivial adjustments of code using mutexes. Mostly removing the
mutex_init() return value check.
* Added mutex_lock_threads_locked(), which is called with the threads
spinlock being held. The spinlock is released while waiting, of
course. This function is useful in cases where the existence of the
mutex object is ensured by holding the threads spinlock.
* Changed the two instances in the VFS code where an IO context of
another team needs to be locked to use mutex_lock_threads_locked().
Before it required a semaphore-based mutex implementation.


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


# 8562499f441ac23a80dd89310dbf2016b681fef9 30-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced a new locking primitive I called "cutex" (sorry for the
name, couldn't resist :-P). It's semantically equivalent to a mutex,
but doesn't need a semaphore (it uses thread blocking and a simple
queue instead). Initialization can't fail. In fact it is ready to use
without initialization when living in the bss segment, also in the
early boot process. It's as fast as a benaphore in cases of low lock
contention, and faster otherwise. Only disadvantage is the higher
immediate memory footprint of 16 bytes.
* Changed how the "thread" and "threads" debugger commands list the
objects they are waiting for. Cutexes are also included.


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


# be8990115c2e3f95c0511d6702e60f5b3fa52f50 27-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Base class of InterruptsLocker was accidentially private.
* Added class InterruptsSpinLocker, which disables interrupts and
acquires a spinlock all in one.


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


# bce7e9f695599da1b2d737e5bee05010ef89a002 09-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added AutoLocker instantiations IterruptsLocker (disables/restores
interrupts) and SpinLocker (acquires/releases spinlocks).
* Adjusted Jamfiles of components that used <util/AutoLock.h> but didn't
add all header directories required now (<int.h> was added).



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


# 2b2ec4382a637811afeb5a4fa812052aef2779c6 26-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Moved the AutoLocker class out of the kernel/utils/AutoLock.h header
into its own shared/AutoLocker.h. It can be used by userland code too.
* Removed headers/private/shared/ObjectLocker.h and replaced all uses of
BObjectLocker by AutoLocker.


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


# 27810ccf5ebf62cf8faaf0a96e93c7a1ddedc491 22-Mar-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added the last useful features I dare imagine: A Lock() method and the
possibility to initialize the AutoLocker without locking the object even
if it is unlocked yet. Especially in loops Lock()/Unlock() come handy
when an otherwise constantly hold lock needs to be unlocked for a short
time.

I suppose we should move the kernel utils AutoLocker implementation
to headers/private/shared, and drop the less powerful ObjectLocker.


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


# aa547f5fbbd3c9128651650f76264a3ec9695c87 07-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

* mutex_lock() and recursive_lock_lock() now return a status_t and report failure.
* recursive_lock_unlock() now returns a void to mirror it's counterpart better;
use recursive_lock_get_recursion() if you're interested in the lock depth.
* switch_sem(), and release_sem() now don't do anything anymore in kernel startup
mode.


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


# 3e15f83d9e66ece1dd78205a74162d5d522055bf 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Added a BenaphoreLocker.


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


# 8af41139d563444d385a42934f259d23eb8e35a5 20-Mar-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Added default constructor. Useful in combination with SetTo().

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


# b6933d8acc9a1849b6a0d66ad6b7eccc86275b29 30-Jan-2005 Ingo Weinhold <ingo_weinhold@gmx.de>

Moved generic auto locking code out of
<disk_device_manager/KDiskDeviceUtils.h> into <util/AutoLock.h>.
Added instantiations for recursive locks (moved from vfs.cpp) and
mutexes.


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