History log of /haiku-fatelf/src/system/kernel/condition_variable.cpp
Revision Date Author Comments
# 0e88a887 13-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

First round of 64-bit safety fixes in the kernel.

* Most of this is incorrect printf format strings. Changed all strings
causing errors to use the B_PRI* format string definitions, which
means the strings should be correct across all platforms.
* Some other fixes for errors, casts required, etc.


# 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


# af983c17 03-Dec-2009 Colin Günther <coling@gmx.de>

Coding style cleanups. Thanks axeld.


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


# 1581b764 02-Dec-2009 Colin Günther <coling@gmx.de>

* Adding static Notify{One,All} functions. This allows a cleaner implementation
of the condition variable and synchronization subsystem of the freebsd compat
layer which will be committed next.
* Also there was a discussion about adding these functions on the commit
mailing list. The mail in http://www.freelists.org/post/haiku-commits/r34395-in-haikutrunksrclibscompatfreebsd-network-compatsys,3
is a good sum up of it (need to scroll somewhat down, though).


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


# 5ee1f125 21-Oct-2009 Michael Lotz <mmlr@mlotz.ch>

Make use of the wait status field so it can be provided in Notify() and then
read out in the ConditionVariableEntry::WaitStatus(). That way you can notify
with a specific status that can be read out on the other end.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33718 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


# 227fe7d3 23-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Scheduler/wait object listener:
- Moved scheduler listening interface to <listeners.h> and added more
convenient to use templatized notification functions.
- Added a listener mechanism for the wait objects (semaphores, condition
variables, mutex, rw_lock).
* system profiler:
- Hopefully fixed locking issues related to notifying the profiler thread
for good. We still had an inconsistent locking order, since the scheduler
notification callbacks are invoked with the thread lock held and have to
acquire the object lock then, while the other callbacks acquired the object
lock first and as a side effect of ConditionVariable::NotifyOne() acquired
the thread lock. Now we make sure the object lock is the innermost lock.
- Track the number of dropped events due to a full buffer.
_user_system_profiler_next_buffer() returns this count now.
- When scheduling profiling events are requested also listen to wait objects
and generate the respective profiling events. We send those events lazily
and cache the infos to avoid resending an event for the same wait object.
- When starting profiling we do now generate "thread scheduled" events for
the already running threads.
- _user_system_profiler_start(): Check whether the parameters pointer is a
userland address at all.
- The system_profiler_team_added event does now also contain the team's name.
* Added a sem_get_name_unsafe() returning a semaphore's name. It is "unsafe",
since the caller has to ensure that the semaphore exists and continues to
exist as long as the returned name is used.
* Adjusted the "profile" and "scheduling_recorder" according to the system
profiling changes. The latter prints the number of dropped events, now.


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


# fd0803f3 06-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Added RemoveTail() method.
* Renamed DoublyLinkedList::Size() to Count(), since it actually counts the
items (ie. O(n)).


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


# 020ac568 03-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed bug in the "scheduler" command: The check when a thread was
unscheduled was incorrect.
* Introduced _kern_analyze_scheduling() syscall. It requires scheduler
kernel tracing to be enabled. It uses the tracing entries for a given
period of time to do a similar analysis the "scheduler" debugger
command does (i.e. number of runs, run time, latencies, preemption
times) for each thread. Additionally the analysis includes for each
thread how long the thread waited on each locking primitive in total.
* Added kernel tracing for the creation of semaphores and initialization
of condition variables, mutexes, and rw locks. The enabling macro is
SCHEDULING_ANALYSIS_TRACING. The only purpose is to provide
_kern_analyze_scheduling() with more info on the locking primitives
(the name in particular).


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


# 1a617f51 03-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

More informative panic().


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


# 15374c5d 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed thread_spinlock and team_spinlock to gThreadSpinlock and
gTeamSpinlock.
* Renamed the static global variables in smp.c to match our style guide.
* Minor other cleanup.
* Removed superfluous white space.


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


# 8cc3c744 28-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

The "cvar" command wasn't happy with private condition variables. Now we
don't check any longer whether the given number is the address of a
condition variable in the global hash table; we just assume it is a
valid condition variable pointer.


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


# 5c99d639 22-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/vm into trunk. This
introduces the following relevant changes:
* VMCache:
- Renamed vm_cache to VMCache, merged it with vm_store and made it a
C++ class with virtual methods (replacing the store operations).
Turned the different store implementations into subclasses.
- Introduced MergeStore() callback, changed semantics of Commit().
- Changed locking and referencing semantics. A reference can only be
acquired/released with the cache locked. An unreferenced cache is
deleted and a mergeable cache merged when it is unlocked. This
removes the "busy" state of a cache and simplifies the page fault
code.
* Added VMAnonymousCache, which will implement swap support (work by
Zhao Shuai). It is not integrated and used yet, though.
* Enabled the mutex/recursive lock holder asserts.
* Fixed DoublyLinkedList::Swap().
* Generalized the low memory handler to a low resource handler. And made
semaphores and reserved memory handled resources. Made
vm_try_resource_memory() optionally wait (with timeout), and used that
feature to reserve memory for areas.
...


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


# cb919155 16-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

bonefish + axeld:
* Removed the superfluous "flags" parameter from ConditionVariable::Add()
that we forgot there when we moved the flags field from
ConditionVariableEntry::Add() to Wait().
* Using this method was therefore not a good idea - only UnixFifo did, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26454 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


# fbe0c27a 17-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Changed condition variables so that it is allowed to block (e.g. lock
mutexes etc.) between Add() and Wait(). This fixes #2059, since the
block writer used them this way and could thusly fail to wait for a
condition variable, causing a temporary stack object to be used past its
lifetime.


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


# 023bf5fc 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for timeouts.
* Added support for non-published condition variables. One has to call
Init() on those, and add entries directly with the
ConditionVariable::Add() method.


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


# 6cef245e 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Detemplatized ConditionVariable{Entry}. Merged them with their
respective Private* base class.
* Changed sigwait() and sigsuspend() to use thread_block() instead of a
condition variable.


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


# b95f6d47 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced a set of functions (thread_prepare_to_block(),
thread_block(), thread_unblock(),...) that allow a thread to wait for
something without needing a semaphore or condition variable. It can
simply block and another thread can unblock it. Supports timeouts and
interrupting. Both semaphores and condition variables use this
common mechanism, now.
* Semaphores:
- Some simplifications due to the thread blocking mechanism.
- Changed locking order to sem -> thread. It was the other way around
before and when introducing the wait_for_objects() support I had
also introduced a situation where the locking was reverse, which
could potentially cause a dead lock on SMP systems.
- Instead of queueing thread structures, a semaphore queues
queued_thread entries now, which are created on the stack. The
thread::sem structure could thus be removed.
- Added sem_entry::net_count, which is sem_entry::count plus the
acquisition count of all waiting threads. This number is needed in
remove_thread_from_sem() and instead of computing it there we
maintain it.
- Fixed remove_thread_from_sem(). It would not unblock threads, if
the sem count was <= 0.
- Made sem::last_acquirer unconditional. It is actually needed for
sem_info::latest_holder. Fixed fill_sem_info() accordingly.
- Added some optional tracing output, though only via ktrace_printf().
* Condition variables:
- Could be simplified significantly through the use of the thread
blocking mechanism. Removed a good deal of unnecessary code.
- Moved the ConditionVariableEntry "flags" parameter from Wait() to
Add(), and adjusted all places where condition variables are used
accordingly.
* snooze() uses thread_block_with_timeout() instead of a semaphore.
* Simplified thread interrupting in the signal and user debugger code.
Instead of separate functions for threads waiting on a semaphore or
condititon variable, we only have a single thread_interrupt(), now.



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


# 8db2e374 20-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed the feature that a thread can wait for more than one condition
variable at once. It wasn't used anymore, and the code gets simpler.


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


# 23b95b11 22-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

We have to remove the thread's condition variable entries when
interrupted early, i.e. when signals were already pending when we
started waiting. Fixes #1832.


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


# fe19cba8 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Before starting to wait on a condition variable check for pending
signals first, if the call is interruptable.


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


# 6761f5a6 25-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Move the handling of still running threads into scheduler_enqueue_in_run_queue().
This should be in line with all uses of scheduler_enqueue_in_run_queue() and
simplifies a few places where it is used.

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


# bd0689e6 17-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added usage message to "cvar" and "cvars" debugger commands and define
temporary variables.


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


# 8609f5a2 01-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Increased condition variable hash size.
* Renamed condition variable debugger commands to cvar and cvars.


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


# d0c2af77 01-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Addressed a deadlock race condition: Acquiration of condition variable
and thread spinlock was reverse in Wait() and Notify(). The thread lock
is now the outer lock -- this way it is still possible to call Notify()
with the thread lock being held.


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


# addece20 02-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed incorrect check in condition_variable_interrupt_thread().
Condition variables would never be interrupted.
* ConditionVariableEntry::Add() did not correctly insert the entry into
the per-thread list of entries (the next link of the previous entry
was not adjusted), which could leave the entry unnotified when the
previous entry was notified, thus leaving it in the respective
condition variable's list after the end of its life time. This should
fix a crashing bug I rarely encountered.
* Added debug checks in the PrivateConditionVariableEntry
constructor/destructor that should have helped me to find
forementioned bug hours earlier, had I been bright enough to realize
that I didn't include <debug.h> and those KDEBUG guarded checks were
never executed. :-/


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


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

fVariable was not correctly unset when the condition variable entry was
removed from the variable, which could lead to crashes under certain
cicrumstances.


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


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

Notify*() and Unpublish() acquire the threads lock. So they need to know
whether the lock is already being held.



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


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

Wait() returns a status_t now, which can be B_OK (condition variable
exists and thread was notified), B_ENTRY_NOT_FOUND (condition variable
not found or Unpublish()ed while waiting), or B_INTERRUPTED
(interrupted by a signal).


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


# ff308b0b 26-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Condition variables changes:
* Removed left-over commented C implementation.
* It is now possible for a thread to wait for more than one condition
variable at a time.
* Made waiting for condition variables optionally interruptable.
* Renamed Notify() method to NotifyAll() and added a NotifyOne(), so
that it is now possible to wake up only one of the waiting threads.
Pretty much untested at the moment.


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


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

Added simple condition variables to the kernel. They are a relatively
cheap means to block threads until notified explicitely.
threads


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


# 0e88a887b4a9ecaaf1062078d9ca9bfca78fcf3a 13-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

First round of 64-bit safety fixes in the kernel.

* Most of this is incorrect printf format strings. Changed all strings
causing errors to use the B_PRI* format string definitions, which
means the strings should be correct across all platforms.
* Some other fixes for errors, casts required, etc.


# 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


# af983c175d62713b0598366f2fc365ba56d46b26 03-Dec-2009 Colin Günther <coling@gmx.de>

Coding style cleanups. Thanks axeld.


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


# 1581b764e0a14e86671bc5193516eedc621610e9 02-Dec-2009 Colin Günther <coling@gmx.de>

* Adding static Notify{One,All} functions. This allows a cleaner implementation
of the condition variable and synchronization subsystem of the freebsd compat
layer which will be committed next.
* Also there was a discussion about adding these functions on the commit
mailing list. The mail in http://www.freelists.org/post/haiku-commits/r34395-in-haikutrunksrclibscompatfreebsd-network-compatsys,3
is a good sum up of it (need to scroll somewhat down, though).


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


# 5ee1f125e59267d8dce4c22c7d030d0310eebbf3 21-Oct-2009 Michael Lotz <mmlr@mlotz.ch>

Make use of the wait status field so it can be provided in Notify() and then
read out in the ConditionVariableEntry::WaitStatus(). That way you can notify
with a specific status that can be read out on the other end.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33718 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


# 227fe7d34aeed45d0727a0abde2ea2309352983b 23-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Scheduler/wait object listener:
- Moved scheduler listening interface to <listeners.h> and added more
convenient to use templatized notification functions.
- Added a listener mechanism for the wait objects (semaphores, condition
variables, mutex, rw_lock).
* system profiler:
- Hopefully fixed locking issues related to notifying the profiler thread
for good. We still had an inconsistent locking order, since the scheduler
notification callbacks are invoked with the thread lock held and have to
acquire the object lock then, while the other callbacks acquired the object
lock first and as a side effect of ConditionVariable::NotifyOne() acquired
the thread lock. Now we make sure the object lock is the innermost lock.
- Track the number of dropped events due to a full buffer.
_user_system_profiler_next_buffer() returns this count now.
- When scheduling profiling events are requested also listen to wait objects
and generate the respective profiling events. We send those events lazily
and cache the infos to avoid resending an event for the same wait object.
- When starting profiling we do now generate "thread scheduled" events for
the already running threads.
- _user_system_profiler_start(): Check whether the parameters pointer is a
userland address at all.
- The system_profiler_team_added event does now also contain the team's name.
* Added a sem_get_name_unsafe() returning a semaphore's name. It is "unsafe",
since the caller has to ensure that the semaphore exists and continues to
exist as long as the returned name is used.
* Adjusted the "profile" and "scheduling_recorder" according to the system
profiling changes. The latter prints the number of dropped events, now.


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


# fd0803f3003a667986c914254b4735254cb4db4e 06-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Added RemoveTail() method.
* Renamed DoublyLinkedList::Size() to Count(), since it actually counts the
items (ie. O(n)).


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


# 020ac568404b8ab78825622d8815be48e987f649 03-Sep-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed bug in the "scheduler" command: The check when a thread was
unscheduled was incorrect.
* Introduced _kern_analyze_scheduling() syscall. It requires scheduler
kernel tracing to be enabled. It uses the tracing entries for a given
period of time to do a similar analysis the "scheduler" debugger
command does (i.e. number of runs, run time, latencies, preemption
times) for each thread. Additionally the analysis includes for each
thread how long the thread waited on each locking primitive in total.
* Added kernel tracing for the creation of semaphores and initialization
of condition variables, mutexes, and rw locks. The enabling macro is
SCHEDULING_ANALYSIS_TRACING. The only purpose is to provide
_kern_analyze_scheduling() with more info on the locking primitives
(the name in particular).


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


# 1a617f516a3a06b29c362acfec4142d31c17b46f 03-Aug-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

More informative panic().


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


# 15374c5dbdb2c6b700bb2191887cadad7ef9eb73 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Renamed thread_spinlock and team_spinlock to gThreadSpinlock and
gTeamSpinlock.
* Renamed the static global variables in smp.c to match our style guide.
* Minor other cleanup.
* Removed superfluous white space.


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


# 8cc3c74406b4b4c4b687fa85f6a5c56989743a56 28-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

The "cvar" command wasn't happy with private condition variables. Now we
don't check any longer whether the given number is the address of a
condition variable in the global hash table; we just assume it is a
valid condition variable pointer.


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


# 5c99d639708df9b4e2cc847b38d510149d19ec78 22-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged branch haiku/branches/developer/bonefish/vm into trunk. This
introduces the following relevant changes:
* VMCache:
- Renamed vm_cache to VMCache, merged it with vm_store and made it a
C++ class with virtual methods (replacing the store operations).
Turned the different store implementations into subclasses.
- Introduced MergeStore() callback, changed semantics of Commit().
- Changed locking and referencing semantics. A reference can only be
acquired/released with the cache locked. An unreferenced cache is
deleted and a mergeable cache merged when it is unlocked. This
removes the "busy" state of a cache and simplifies the page fault
code.
* Added VMAnonymousCache, which will implement swap support (work by
Zhao Shuai). It is not integrated and used yet, though.
* Enabled the mutex/recursive lock holder asserts.
* Fixed DoublyLinkedList::Swap().
* Generalized the low memory handler to a low resource handler. And made
semaphores and reserved memory handled resources. Made
vm_try_resource_memory() optionally wait (with timeout), and used that
feature to reserve memory for areas.
...


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


# cb9191556c39d4321b6dc700532eb74f598d166d 16-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

bonefish + axeld:
* Removed the superfluous "flags" parameter from ConditionVariable::Add()
that we forgot there when we moved the flags field from
ConditionVariableEntry::Add() to Wait().
* Using this method was therefore not a good idea - only UnixFifo did, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26454 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


# fbe0c27a94fff9dff7c42e12ee96f789b314c746 17-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Changed condition variables so that it is allowed to block (e.g. lock
mutexes etc.) between Add() and Wait(). This fixes #2059, since the
block writer used them this way and could thusly fail to wait for a
condition variable, causing a temporary stack object to be used past its
lifetime.


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


# 023bf5fcda8c37eb8e295784608ce818384a0ca5 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for timeouts.
* Added support for non-published condition variables. One has to call
Init() on those, and add entries directly with the
ConditionVariable::Add() method.


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


# 6cef245eca821584f07f5a13558f51ec586852e8 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Detemplatized ConditionVariable{Entry}. Merged them with their
respective Private* base class.
* Changed sigwait() and sigsuspend() to use thread_block() instead of a
condition variable.


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


# b95f6d4710855a27bec41b6fae2b064347780173 22-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced a set of functions (thread_prepare_to_block(),
thread_block(), thread_unblock(),...) that allow a thread to wait for
something without needing a semaphore or condition variable. It can
simply block and another thread can unblock it. Supports timeouts and
interrupting. Both semaphores and condition variables use this
common mechanism, now.
* Semaphores:
- Some simplifications due to the thread blocking mechanism.
- Changed locking order to sem -> thread. It was the other way around
before and when introducing the wait_for_objects() support I had
also introduced a situation where the locking was reverse, which
could potentially cause a dead lock on SMP systems.
- Instead of queueing thread structures, a semaphore queues
queued_thread entries now, which are created on the stack. The
thread::sem structure could thus be removed.
- Added sem_entry::net_count, which is sem_entry::count plus the
acquisition count of all waiting threads. This number is needed in
remove_thread_from_sem() and instead of computing it there we
maintain it.
- Fixed remove_thread_from_sem(). It would not unblock threads, if
the sem count was <= 0.
- Made sem::last_acquirer unconditional. It is actually needed for
sem_info::latest_holder. Fixed fill_sem_info() accordingly.
- Added some optional tracing output, though only via ktrace_printf().
* Condition variables:
- Could be simplified significantly through the use of the thread
blocking mechanism. Removed a good deal of unnecessary code.
- Moved the ConditionVariableEntry "flags" parameter from Wait() to
Add(), and adjusted all places where condition variables are used
accordingly.
* snooze() uses thread_block_with_timeout() instead of a semaphore.
* Simplified thread interrupting in the signal and user debugger code.
Instead of separate functions for threads waiting on a semaphore or
condititon variable, we only have a single thread_interrupt(), now.



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


# 8db2e374929b7ac0cf11a064c93fefff5926588d 20-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Removed the feature that a thread can wait for more than one condition
variable at once. It wasn't used anymore, and the code gets simpler.


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


# 23b95b112db936067bdf4188974680b562099587 22-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

We have to remove the thread's condition variable entries when
interrupted early, i.e. when signals were already pending when we
started waiting. Fixes #1832.


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


# fe19cba8f06ac099d9731551380ef372bc96ae9a 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Before starting to wait on a condition variable check for pending
signals first, if the call is interruptable.


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


# 6761f5a660bcba247e0967e09ac58f2f4488bd55 25-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Move the handling of still running threads into scheduler_enqueue_in_run_queue().
This should be in line with all uses of scheduler_enqueue_in_run_queue() and
simplifies a few places where it is used.

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


# bd0689e66829b9e05545c831cc817ba069224acc 17-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added usage message to "cvar" and "cvars" debugger commands and define
temporary variables.


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


# 8609f5a242bff1992094f81f7ac71ca3b67c13c4 01-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Increased condition variable hash size.
* Renamed condition variable debugger commands to cvar and cvars.


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


# d0c2af771393d353dde1f0375d1edbf1f410be50 01-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Addressed a deadlock race condition: Acquiration of condition variable
and thread spinlock was reverse in Wait() and Notify(). The thread lock
is now the outer lock -- this way it is still possible to call Notify()
with the thread lock being held.


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


# addece2001c2683709aec70ec48f91fa142c0752 02-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed incorrect check in condition_variable_interrupt_thread().
Condition variables would never be interrupted.
* ConditionVariableEntry::Add() did not correctly insert the entry into
the per-thread list of entries (the next link of the previous entry
was not adjusted), which could leave the entry unnotified when the
previous entry was notified, thus leaving it in the respective
condition variable's list after the end of its life time. This should
fix a crashing bug I rarely encountered.
* Added debug checks in the PrivateConditionVariableEntry
constructor/destructor that should have helped me to find
forementioned bug hours earlier, had I been bright enough to realize
that I didn't include <debug.h> and those KDEBUG guarded checks were
never executed. :-/


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


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

fVariable was not correctly unset when the condition variable entry was
removed from the variable, which could lead to crashes under certain
cicrumstances.


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


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

Notify*() and Unpublish() acquire the threads lock. So they need to know
whether the lock is already being held.



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


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

Wait() returns a status_t now, which can be B_OK (condition variable
exists and thread was notified), B_ENTRY_NOT_FOUND (condition variable
not found or Unpublish()ed while waiting), or B_INTERRUPTED
(interrupted by a signal).


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


# ff308b0b491531f2f3b5d22244d7ac5904133e61 26-Aug-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Condition variables changes:
* Removed left-over commented C implementation.
* It is now possible for a thread to wait for more than one condition
variable at a time.
* Made waiting for condition variables optionally interruptable.
* Renamed Notify() method to NotifyAll() and added a NotifyOne(), so
that it is now possible to wake up only one of the waiting threads.
Pretty much untested at the moment.


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


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

Added simple condition variables to the kernel. They are a relatively
cheap means to block threads until notified explicitely.
threads


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