History log of /haiku-fatelf/src/system/kernel/posix/xsi_semaphore.cpp
Revision Date Author Comments
# 4be4fc6b 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# 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


# cee04e80 08-Feb-2010 Artur Wyszynski <aljen-mlists@o2.pl>

Fixed various errors/warnings reported by cppcheck:
* memory leaks
* resource leaks
* added const's to getters
* removed a few reundant conditions


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


# 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


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

* Order members alphabetically. No functional changes


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


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

* split Wait() method into Enqueue() - BlockAndUnlock() - Deque() in order to
remove a race condition pointed out by Ingo, hopefully in a clean way. The
set is now unlocked right before blocking
* Reworked the way ID were assgned: the current time is now used as ID. This
lower quite a lot the probability of having an ID reused.
* Introduced a sequence number field in the set class as a second ID, as
suggested by Ingo. It is used on wake up in order not to confuse a no more
existing set with a new one with the same ID
* Removed a now unnecessary UnsetID() method
* Increased the arbitraty limit of max sempahore allowed in the system, and
introduced a new one for the total number of set.



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


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

* Fix a potential race condition when deleting a semaphore set: previously only
the ipc hash table lock along with the semaphore set hash table lock were
hold, thinking (wrongly) that the semaphore set lock itself was not needed.
What could happen was that another process on semop could have gained the lock
of the set itself, and then release the semaphore set hash table lock.
This would make it think that the set was still valid, while it could have
actually been deleted right after it release the semaphore set hash table lock.
Same would have happened for any other processes waiting on the semaphore set
mutex queue. By calling the lock on the mutex when deleting the set, it
*should be* safe to assume that there is no one else waiting on its queue,
since the list of waiters is handled in a FIFO way.

As far as I can see from the mutex_destroy code, it looks safe to hold the lock
when calling this function. Please confirm.


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


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

* Renamed xsi_ipc_init() to xsi_sem_init() as there will be a xsi_msg_init()
for message queue
* Removed unnecessary header Vector.h
* Removed HasSemaphoreSet method: since there will be an IPC table for each
subsystem, if a key exist, it already has a semaphore set associated
with it


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


# 6ae7f687 16-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Reworked the way sem_undo requests are processed by following
Ingo suggestions: instead of having one global sem_undo list,
we now have two local list, one per semaphore set and one per team
which is held in its xsi_sem_context structure, along with a mutex.
A mutex has also been added to the semaphore set class in order to
protect the local list, but also in order to (hopefully) improve
concurrency.


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


# 79f556e5 05-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Check for wake ups on Revert()
* Fix TRACE() output
* Check for IPC_CREAT in xsi_semget when IPC does not yet exist
* Fix bound checking
* Fix setpid call



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


# 51daeb71 02-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

- Fixed warnings
- Fixed deadlock in xsi_sem_undo - RecordUndo
- Fixed issue in xsi_sem_undo: if the semaphore set does not exist
anymore, ignore the request but do remove the process from the sUndoList,
which wasn't previously done.
- free() in ClearUndos was called with interrupts disabled
- when a semaphore set ends to exist, remove all it's sem_undo request as it's ID
will be reused in the future.



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


# 47ca7595 28-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

First patch by Salvatore to implement XSI semaphores with a few changes
by myself:
* renamed xsi_do_undo() to xsi_sem_undo() (there is more to XSI than sems).
* Fixed coding style issues in sys/sem.h and xsi_sem.cpp.
* Added _kern_*() syscall prototypes to syscalls.h.
* Added a TODO in xsi_sem.cpp and xsi_semaphore.h about moving union semun to
a shared header.
* Made the team::xsi_sem_undo_requests int32 - due to padding, it would have
needed 4 bytes anyway; please always use specific types over int/short/long.
* xsi_sem_undo() now checks if it needs to do anything - the calls in team.cpp
no longer needs to do this.


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


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

More 64-bit compilation/safety fixes.


# 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


# cee04e8074ec61fd8c6dac3539c5b821c3618888 08-Feb-2010 Artur Wyszynski <aljen-mlists@o2.pl>

Fixed various errors/warnings reported by cppcheck:
* memory leaks
* resource leaks
* added const's to getters
* removed a few reundant conditions


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


# 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


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

* Order members alphabetically. No functional changes


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


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

* split Wait() method into Enqueue() - BlockAndUnlock() - Deque() in order to
remove a race condition pointed out by Ingo, hopefully in a clean way. The
set is now unlocked right before blocking
* Reworked the way ID were assgned: the current time is now used as ID. This
lower quite a lot the probability of having an ID reused.
* Introduced a sequence number field in the set class as a second ID, as
suggested by Ingo. It is used on wake up in order not to confuse a no more
existing set with a new one with the same ID
* Removed a now unnecessary UnsetID() method
* Increased the arbitraty limit of max sempahore allowed in the system, and
introduced a new one for the total number of set.



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


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

* Fix a potential race condition when deleting a semaphore set: previously only
the ipc hash table lock along with the semaphore set hash table lock were
hold, thinking (wrongly) that the semaphore set lock itself was not needed.
What could happen was that another process on semop could have gained the lock
of the set itself, and then release the semaphore set hash table lock.
This would make it think that the set was still valid, while it could have
actually been deleted right after it release the semaphore set hash table lock.
Same would have happened for any other processes waiting on the semaphore set
mutex queue. By calling the lock on the mutex when deleting the set, it
*should be* safe to assume that there is no one else waiting on its queue,
since the list of waiters is handled in a FIFO way.

As far as I can see from the mutex_destroy code, it looks safe to hold the lock
when calling this function. Please confirm.


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


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

* Renamed xsi_ipc_init() to xsi_sem_init() as there will be a xsi_msg_init()
for message queue
* Removed unnecessary header Vector.h
* Removed HasSemaphoreSet method: since there will be an IPC table for each
subsystem, if a key exist, it already has a semaphore set associated
with it


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


# 6ae7f6879ff2131f94b47b14764f65115d9bfdbc 16-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Reworked the way sem_undo requests are processed by following
Ingo suggestions: instead of having one global sem_undo list,
we now have two local list, one per semaphore set and one per team
which is held in its xsi_sem_context structure, along with a mutex.
A mutex has also been added to the semaphore set class in order to
protect the local list, but also in order to (hopefully) improve
concurrency.


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


# 79f556e5a6ebd13fbc8e39b275919551b6349c39 05-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

* Check for wake ups on Revert()
* Fix TRACE() output
* Check for IPC_CREAT in xsi_semget when IPC does not yet exist
* Fix bound checking
* Fix setpid call



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


# 51daeb7147ec5e457bca3a3acb7643ec92318d83 02-Aug-2008 Salvatore Benedetto <salvatore.benedetto@gmail.com>

- Fixed warnings
- Fixed deadlock in xsi_sem_undo - RecordUndo
- Fixed issue in xsi_sem_undo: if the semaphore set does not exist
anymore, ignore the request but do remove the process from the sUndoList,
which wasn't previously done.
- free() in ClearUndos was called with interrupts disabled
- when a semaphore set ends to exist, remove all it's sem_undo request as it's ID
will be reused in the future.



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


# 47ca7595ca54e08dac7482950a35b045e6ad8801 28-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

First patch by Salvatore to implement XSI semaphores with a few changes
by myself:
* renamed xsi_do_undo() to xsi_sem_undo() (there is more to XSI than sems).
* Fixed coding style issues in sys/sem.h and xsi_sem.cpp.
* Added _kern_*() syscall prototypes to syscalls.h.
* Added a TODO in xsi_sem.cpp and xsi_semaphore.h about moving union semun to
a shared header.
* Made the team::xsi_sem_undo_requests int32 - due to padding, it would have
needed 4 bytes anyway; please always use specific types over int/short/long.
* xsi_sem_undo() now checks if it needs to do anything - the calls in team.cpp
no longer needs to do this.


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