History log of /haiku/src/servers/app/MultiLocker.h
Revision Date Author Comments
# fd97a8c7 27-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

app_server: Use a rw_lock instead of 3 (!) semaphores for MultiLocker.

Since every HWInterface is a MultiLocker, and every BBitmap requires
a server-side BitmapHWInterface, this saves 3 semaphores per BBitmap
instance (as well as a lot of semaphore-related overhead in calling
the kernel so often.)


# f9c77b11 27-Jul-2019 Augustin Cavalier <waddlesplash@gmail.com>

app_server: Clean up MultiLocker::IsWriteLocked().

This function was (or at least now is) severely over-engineered:
it is designed to avoid calling find_thread(NULL) as little
as possible, and use stack addresses to determine if the current
thread is the one holding the write lock.

However, this is unneccessary, as find_thread(NULL) has been
optimized (on x86 and x86_64, at least) to be a single "mov"
from thread-local data, with no syscall. So that is probably
even faster than an integer divide and compare, allowing
this function to be simplified greatly.


# 3fed1a15 05-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Get app_server working on x86_64.

With this commit, app_server now compiles and runs at boot! Nothing
particularly interesting happens, just the blue background and a mouse
pointer. Remote backends are broken and not compiled in, see #8834.
Note that it won't be possible to build this quite yet, need to get
the FreeType package uploaded.


# d5314ec0 24-Jul-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

* It helps a lot to find thread problems when the multi locker assert macros actually doing something useful. Took me forever to finally realise that and to find a threading bug.
* Remove a superfluously assert which sends the app server into the debugger. More fixes following.



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


# 8b56f14a 12-Mar-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed debug build.


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


# 78ca6157 27-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Changed AS_GET_SCREEN_ID_FROM_WINDOW as well as AS_SCREEN_GET_MODE to no
longer hold the window lock. There is now a lock that guards screen changes
in particular. This fixes the deadlocks seen in apps using BDirectWindow.
* All direct window handling now sits in the Desktop class -
ServerWindow::HandleDirectConnection() is never called from anywhere else
anymore. Furthermore, it's now only called when actually needed.
* Resize/move actions now always send a B_CLIPPING_MODIFIED flag, too.
* When the screen changed, the driver state is supposed to be B_MODE_CHANGED,
not B_SCREEN_CHANGED (which is a message constant).
* Direct windows are no longer suspended too late on screen changes.
* Removed unused members of DirectWindowData, and cleaned it up a bit.
* Made MultiLocker's default, and copy constructors private - I accidently
used them, causing the ASSERT_MULTI_*LOCKED() macros to fail.
* Added Unlock() to AutoWriteLocker as well.
* Minor cleanup.


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


# 0eed9183 20-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Rewrote screen configuration management: VirtualScreen doesn't have anything
to do with the configurations now, instead, there is a separated
ScreenConfigurations class that maintains all known screen_configurations
per workspace (and the Workspace::Private class has two of them, one for the
current modes, one for the stored modes).
* Added Desktop::{Get|Set}ScreenMode() methods, ServerApp now only calls those.
* Getting and setting of anything else than the current screen is now supported.
* This change also fixes that a temporarily set screen mode was not being
restored on workspace switch.
* Also, the Deskbar now seems to have the wrong location a lot, which is
something that should be easily fixable therefore. I will look into this next.
* Got rid of the unhandy screen_id structure server side, and in BPrivateScreen;
we now just use an int32 - the next API break should definitely replace the
screen_id with a simple typedef.
* Some cleanup.


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


# 78f1b0e9 02-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* added IsLocked() method to AutoWriteLocker


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


# 4d1fd46c 02-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

* Replaced DEBUG MultiLocker with an implementation that actually helps debugging
locking problems (instead of debugging the locker class).
* MultiLocker::IsReadLocked() is now only exported with DEBUG mode turned on, as
it only works correctly in this case.
* Made MultiLocker safe against B_INTERRUPTED, ie. it now just tries to lock again
instead of failing for no obvious reason.
* Removed bogus arguments to acquire_sem_etc() in MultiLocker (like B_DO_NOT_RESCHEDULE).
* Applied coding style to MultiLocker.


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


# 2cfe93e7 04-Dec-2006 Stephan Aßmus <superstippi@gmx.de>

* renamed HWInterface locking to LockParallelAccess() and
LockExclusiveAccess() (meaning more or less access to the
frame buffer)
* extracted the AGGTextRenderer to be a global instance used
by each Painter instance (currently, it is thread safe because
of the global font lock, so there is some work left in this
regard)
* gave every ServerWindow it's own DrawingEngine instance, this
is work in progress. So far, there doesn't seem to be a regression,
but less fighting over the exclusive access to the frame buffer, now
each ServerWindow thread can draw in parallel. There is room for
improvement, plus I think I'm leaking the DrawingEngine...
* changed the locking for the software cursor. ShowSoftwareCursor()
can only be called if HideSoftwareCursor(BRect) returned true, or
if you called the generic HideSoftwareCursor(), since it needs
to keep the cursor lock and unlocks in Show...!
* some clean up and renaming in Decorator and friends
* moved PatternHandler.h to live along with the .cpp


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


# 39c9925f 07-Apr-2006 Stephan Aßmus <superstippi@gmx.de>

* implemented a BRegion pool per WindowLayer which is supposed
to cut down on BRegion related allocations, cannot really tell
if it speeds things up
* used the new BRegion pool in WindowLayer and ViewLayer whereever
a BRegion was used on the stack
* fixed the debugging stuff in MultiLocker - it will get you into
the debugger if you
- try to nest read locks
- try to write lock when your are a reader already
- don't match up nested locks when your a writer
-> but only if you #define DEBUG 1 in the .cpp, is off by default now
* went over WindowLayer, ServerWindow, Desktop and a few other places
and fixed the locking for use with the MultiLocker, the "a reader can
not become a writer" is especially tricky, feel free to review the
changes
* activated the MultiLocker, I tested this quite a bit, if there are
problems simply turn on DEBUG and you should drop into the debugger
right where the problem is... hope all is good


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


# 3dcb3b07 23-Jun-2005 Stephan Aßmus <superstippi@gmx.de>

Added some root layer locking in ServerWindow.cpp when accessing the layer tree. Moved HWInterface management out of DisplayDriverPainter and into Desktop. Removed all the directly hardware related functions from DisplayDriver API. They just called the same HWInterface functions. Now DisplayDriver is much cleaner and ready for being attached to a yet to be written BitmapHWInterface. Clean up of the display mode stuff in Screen and the View-/AccelerantHWInterface. Frequency is now regarded on Haiku. AccelerantHWInterface::GetModeList now works before SetMode has been called. Added MultiLocker from the sample code. HWInterface uses it now in preparation to being used from multiple instances of DisplayDriver.

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


# 3fed1a15f58e8d6fe6b492f3b94bb3625ffeddbd 05-Aug-2012 Alex Smith <alex@alex-smith.me.uk>

Get app_server working on x86_64.

With this commit, app_server now compiles and runs at boot! Nothing
particularly interesting happens, just the blue background and a mouse
pointer. Remote backends are broken and not compiled in, see #8834.
Note that it won't be possible to build this quite yet, need to get
the FreeType package uploaded.


# d5314ec095b26892b07dc9aa51a3d8db9eee6213 24-Jul-2011 Clemens Zeidler <clemens.zeidler@googlemail.com>

* It helps a lot to find thread problems when the multi locker assert macros actually doing something useful. Took me forever to finally realise that and to find a threading bug.
* Remove a superfluously assert which sends the app server into the debugger. More fixes following.



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


# 8b56f14aeba18bc3cea7e8f12708c7b155b374fa 12-Mar-2010 Stephan Aßmus <superstippi@gmx.de>

Fixed debug build.


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


# 78ca6157b696f676eaa004e60d7d055f186df204 27-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Changed AS_GET_SCREEN_ID_FROM_WINDOW as well as AS_SCREEN_GET_MODE to no
longer hold the window lock. There is now a lock that guards screen changes
in particular. This fixes the deadlocks seen in apps using BDirectWindow.
* All direct window handling now sits in the Desktop class -
ServerWindow::HandleDirectConnection() is never called from anywhere else
anymore. Furthermore, it's now only called when actually needed.
* Resize/move actions now always send a B_CLIPPING_MODIFIED flag, too.
* When the screen changed, the driver state is supposed to be B_MODE_CHANGED,
not B_SCREEN_CHANGED (which is a message constant).
* Direct windows are no longer suspended too late on screen changes.
* Removed unused members of DirectWindowData, and cleaned it up a bit.
* Made MultiLocker's default, and copy constructors private - I accidently
used them, causing the ASSERT_MULTI_*LOCKED() macros to fail.
* Added Unlock() to AutoWriteLocker as well.
* Minor cleanup.


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


# 0eed9183061a7763972bc2589f9c43489cd078ab 20-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Rewrote screen configuration management: VirtualScreen doesn't have anything
to do with the configurations now, instead, there is a separated
ScreenConfigurations class that maintains all known screen_configurations
per workspace (and the Workspace::Private class has two of them, one for the
current modes, one for the stored modes).
* Added Desktop::{Get|Set}ScreenMode() methods, ServerApp now only calls those.
* Getting and setting of anything else than the current screen is now supported.
* This change also fixes that a temporarily set screen mode was not being
restored on workspace switch.
* Also, the Deskbar now seems to have the wrong location a lot, which is
something that should be easily fixable therefore. I will look into this next.
* Got rid of the unhandy screen_id structure server side, and in BPrivateScreen;
we now just use an int32 - the next API break should definitely replace the
screen_id with a simple typedef.
* Some cleanup.


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


# 78f1b0e97c9530015ace063c7dfad2080c3b4423 02-Aug-2007 Stephan Aßmus <superstippi@gmx.de>

* added IsLocked() method to AutoWriteLocker


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


# 4d1fd46cdf49413c13bf55d392d5315457f3aa68 02-Feb-2007 Axel Dörfler <axeld@pinc-software.de>

* Replaced DEBUG MultiLocker with an implementation that actually helps debugging
locking problems (instead of debugging the locker class).
* MultiLocker::IsReadLocked() is now only exported with DEBUG mode turned on, as
it only works correctly in this case.
* Made MultiLocker safe against B_INTERRUPTED, ie. it now just tries to lock again
instead of failing for no obvious reason.
* Removed bogus arguments to acquire_sem_etc() in MultiLocker (like B_DO_NOT_RESCHEDULE).
* Applied coding style to MultiLocker.


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


# 2cfe93e7804edb2817dba26ba9b908efbfa80b06 04-Dec-2006 Stephan Aßmus <superstippi@gmx.de>

* renamed HWInterface locking to LockParallelAccess() and
LockExclusiveAccess() (meaning more or less access to the
frame buffer)
* extracted the AGGTextRenderer to be a global instance used
by each Painter instance (currently, it is thread safe because
of the global font lock, so there is some work left in this
regard)
* gave every ServerWindow it's own DrawingEngine instance, this
is work in progress. So far, there doesn't seem to be a regression,
but less fighting over the exclusive access to the frame buffer, now
each ServerWindow thread can draw in parallel. There is room for
improvement, plus I think I'm leaking the DrawingEngine...
* changed the locking for the software cursor. ShowSoftwareCursor()
can only be called if HideSoftwareCursor(BRect) returned true, or
if you called the generic HideSoftwareCursor(), since it needs
to keep the cursor lock and unlocks in Show...!
* some clean up and renaming in Decorator and friends
* moved PatternHandler.h to live along with the .cpp


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


# 39c9925fcf718dbb8c8d5342997d6bbd40f9e7e4 07-Apr-2006 Stephan Aßmus <superstippi@gmx.de>

* implemented a BRegion pool per WindowLayer which is supposed
to cut down on BRegion related allocations, cannot really tell
if it speeds things up
* used the new BRegion pool in WindowLayer and ViewLayer whereever
a BRegion was used on the stack
* fixed the debugging stuff in MultiLocker - it will get you into
the debugger if you
- try to nest read locks
- try to write lock when your are a reader already
- don't match up nested locks when your a writer
-> but only if you #define DEBUG 1 in the .cpp, is off by default now
* went over WindowLayer, ServerWindow, Desktop and a few other places
and fixed the locking for use with the MultiLocker, the "a reader can
not become a writer" is especially tricky, feel free to review the
changes
* activated the MultiLocker, I tested this quite a bit, if there are
problems simply turn on DEBUG and you should drop into the debugger
right where the problem is... hope all is good


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


# 3dcb3b079ab645a90859eba6505cf2692c291138 23-Jun-2005 Stephan Aßmus <superstippi@gmx.de>

Added some root layer locking in ServerWindow.cpp when accessing the layer tree. Moved HWInterface management out of DisplayDriverPainter and into Desktop. Removed all the directly hardware related functions from DisplayDriver API. They just called the same HWInterface functions. Now DisplayDriver is much cleaner and ready for being attached to a yet to be written BitmapHWInterface. Clean up of the display mode stuff in Screen and the View-/AccelerantHWInterface. Frequency is now regarded on Haiku. AccelerantHWInterface::GetModeList now works before SetMode has been called. Added MultiLocker from the sample code. HWInterface uses it now in preparation to being used from multiple instances of DisplayDriver.

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