Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Acquiring a global lock in SWT GTK implementation

Dear all,

Is there any reasons why in org.eclipse.swt.internal.gtk.OS class, we need to use a global lock to access any _g* functions as shown below:

public static final int gdk_drawable_get_depth(long /*int*/ drawable) {
    lock.lock();
    try {
        return _gdk_drawable_get_depth(drawable);
    } finally {
        lock.unlock();
    }
}

I ask this question because locks can cause performance impact badly, especially if we use multiple threads to draw on its private image (not shared image). We have experimented using 32 java threads (on top of 32 hardware threads) to draw on 7680×4320 (33 million pixels) on Linux/GTK platform, and 94% of the total execution time of the application is spent on lock.

Thus, do we need to wrap gdk native routines with a global lock ? Is it possible to avoid lock if we just want to draw on "private" image or private GC ? The reason we use multiple threads is we want to draw in parallel, but unfortunately due to lock, the drawing is serialized.

On a separate issue: is org.eclipse.swt.internal.Lock implementation scalable ? Some lock contention free algorithms such as MCS lock is perhaps more suitable ?

Regards,

Laksono Adhianto

Back to the top