History log of /haiku/headers/private/kernel/sem.h
Revision Date Author Comments
# 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


# ddbe1200 22-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Semaphores are now put into the team struct in a doubly linked list.
* This makes sem_delete_owned_sems() a lot more efficient; before it would need
to scan the entire semaphore table.
* This speeds up the test build of the kernel by another 2 seconds (with
KDEBUG=2) on my laptop.


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


# 5142c2ac 05-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for POSIX semaphores (the ones from the XSI extension
Realtime option group). The implementation should be complete, but is
totally untested yet.


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


# 636bfc08 02-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of
vfs_select.h, respectively moved most of it into the new kernel
private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
work pretty much like poll(), but also for semaphores, ports, and
threads.
* Removed the "ref" parameter from notify_select_events() and the
select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
is no longer needed. The FS interface select() hook still has it,
though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
pair, now. Added respective functions for semaphores, ports, and
threads.



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


# 74b043d9 17-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Removed execute property that was set accidently (since CVS days).


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


# 34e92cad 17-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Added and implemented new system calls switch_sem() and switch_sem_etc(); even if
they are public now, they might become private later on.
It's almost the same as acquire_sem() but allows you to release another semaphore
atomically. This makes condvar implementations and the like very simple to do.
Added B_CHECK_PERMISSION flags to the user calls, although it's not honored yet.


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


# 7028b4da 30-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Cleanup, made C++ safe, updated license.


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


# 50b844ee 30-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Removed the _user_delete_sem_etc() syscall prototype, as it is no longer present.


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


# 383cdedb 28-Aug-2004 Ingo Weinhold <ingo_weinhold@gmx.de>

Several follow-up changes required by the changes either to the VFS
syscalls or to the syscall mechanism (which exposed naming and parameter
inconsistencies).


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


# f6a31876 21-Apr-2004 Axel Dörfler <axeld@pinc-software.de>

Added system_info.h header and syscall for get_system_info().
Added support functions in sem.h and port.h that return some stats.


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


# 564cba31 03-May-2003 Axel Dörfler <axeld@pinc-software.de>

Some header work: removed unnecessary dependencies to stage2.h, fixed
some broken C++ export definitions, added missing licenses etc.


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


# 8fe70e82 25-Oct-2002 lillo <lillo@nowhere.fake>

beos compatibility fixes: exit_thread now issues a signal; wait_for_thread returns B_INTERRUPTED if target thread gets killed


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


# e96a8449 04-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Removed some type definitions from ktypes.h that are now located in OS.h.
Changed lock.h to like those changes.
Moved the create_sem_etc() from the public OS.h to the private kernel only
sem.h, cleaned it up a bit.
gcc doesn't seem to like the "extern inlines" with -O0 -g, so I replaced
an inline function in thread.h with "static inline" (which it does always
like).


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


# 90abd04b 02-Sep-2002 beveloper <beveloper@nowhere.fake>

Change int into status_t, and other changes for better BeOS type compatiblitly.


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


# 3cfbecf1 02-Aug-2002 lillo <lillo@nowhere.fake>

First round of big changes: the term team has replaced proc all over the kernel, the few kern_* syscalls have been renamed to sys_* for consistency, and other small changes. The ps app is temporarily disabled until get_next_team_info is implemented.


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


# ba948746 18-Jul-2002 Axel Dörfler <axeld@pinc-software.de>

Added a fs_get_vnode_name() call for the file systems.
Fixed a header dependency in sem.h.


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


# 52a38012 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


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


# ddbe12007a455315c7904deeea339dc8827c66ad 22-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Semaphores are now put into the team struct in a doubly linked list.
* This makes sem_delete_owned_sems() a lot more efficient; before it would need
to scan the entire semaphore table.
* This speeds up the test build of the kernel by another 2 seconds (with
KDEBUG=2) on my laptop.


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


# 5142c2ac86c0f020ffa3fc31cea9f1f2f1b6ef91 05-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for POSIX semaphores (the ones from the XSI extension
Realtime option group). The implementation should be complete, but is
totally untested yet.


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


# 636bfc08aeaaa7f1bab813c5aa2e8e666b40ec64 02-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of
vfs_select.h, respectively moved most of it into the new kernel
private header wait_for_objects.h.
* Added new experimental API functions wait_for_objects[_etc](). They
work pretty much like poll(), but also for semaphores, ports, and
threads.
* Removed the "ref" parameter from notify_select_events() and the
select_sync_pool functions as well as from fd_ops::fd_[de]select(). It
is no longer needed. The FS interface select() hook still has it,
though -- the VFS will always pass 0.
* de]select_fd() take a select_info* instead of a select_sync* + ref
pair, now. Added respective functions for semaphores, ports, and
threads.



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


# 74b043d98d35652a6892fc430537a02f5f9d9f76 17-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Removed execute property that was set accidently (since CVS days).


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


# 34e92cad76487b81bc77a7973f5595eabdc900d4 17-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Added and implemented new system calls switch_sem() and switch_sem_etc(); even if
they are public now, they might become private later on.
It's almost the same as acquire_sem() but allows you to release another semaphore
atomically. This makes condvar implementations and the like very simple to do.
Added B_CHECK_PERMISSION flags to the user calls, although it's not honored yet.


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


# 7028b4da5d158173d38515f143d1ef081a255eef 30-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Cleanup, made C++ safe, updated license.


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


# 50b844ee0b775050f29f172e3f4dcc5d92704d38 30-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Removed the _user_delete_sem_etc() syscall prototype, as it is no longer present.


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


# 383cdedbd2f1de98851f38bf12d8edef67346ffd 28-Aug-2004 Ingo Weinhold <ingo_weinhold@gmx.de>

Several follow-up changes required by the changes either to the VFS
syscalls or to the syscall mechanism (which exposed naming and parameter
inconsistencies).


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


# f6a31876cec8cc0154a6be366fc623925e64e622 21-Apr-2004 Axel Dörfler <axeld@pinc-software.de>

Added system_info.h header and syscall for get_system_info().
Added support functions in sem.h and port.h that return some stats.


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


# 564cba312ebe49860fbb8416737c4de3e6ccd5f2 03-May-2003 Axel Dörfler <axeld@pinc-software.de>

Some header work: removed unnecessary dependencies to stage2.h, fixed
some broken C++ export definitions, added missing licenses etc.


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


# 8fe70e8212d0de7e9d252885d37d81fbf1787db4 25-Oct-2002 lillo <lillo@nowhere.fake>

beos compatibility fixes: exit_thread now issues a signal; wait_for_thread returns B_INTERRUPTED if target thread gets killed


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


# e96a844909dac884bab3c194f73b158e428e7481 04-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Removed some type definitions from ktypes.h that are now located in OS.h.
Changed lock.h to like those changes.
Moved the create_sem_etc() from the public OS.h to the private kernel only
sem.h, cleaned it up a bit.
gcc doesn't seem to like the "extern inlines" with -O0 -g, so I replaced
an inline function in thread.h with "static inline" (which it does always
like).


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


# 90abd04b348716bc5d8bd597fb059e4f5f33fcfb 02-Sep-2002 beveloper <beveloper@nowhere.fake>

Change int into status_t, and other changes for better BeOS type compatiblitly.


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


# 3cfbecf1a6bfb811556eed42284ad75f9568a9fe 02-Aug-2002 lillo <lillo@nowhere.fake>

First round of big changes: the term team has replaced proc all over the kernel, the few kern_* syscalls have been renamed to sys_* for consistency, and other small changes. The ps app is temporarily disabled until get_next_team_info is implemented.


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


# ba94874630ad8aae849913f5246b24d41890bf37 18-Jul-2002 Axel Dörfler <axeld@pinc-software.de>

Added a fs_get_vnode_name() call for the file systems.
Fixed a header dependency in sem.h.


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


# 52a380120846174213ccce9c4aab0dda17c72083 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


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