Skip to content

wayland: Allow mapping more than one shm buffer at the same time

Vlad Zahorodnii requested to merge work/zzag/shm-client-buffer-map into master

The shared memory buffer may need to install a SIGBUS handler if the compositor may access the data outside of the buffer.

However, signal handling requires great care. For the simplicity sake, only one shared memory buffer is allowed to be accessed at the time. But such a restricted access policy is inconvenient and requires us making client buffer contents copies.

This change eases the restrictions on map() and unmap() functions so several buffers can be accessed simulatenously.

Note that atomic pointers are used because a signal handler can be invoked at any point in the main thread's execution. Even though "a = b" is a single operation from the developer's pov, it can take several steps for the CPU to store a new value to the variable. The atomic pointers ensure that assignments to the next and s_accessedBuffers happen atomically.

Also keep in mind that we cannot start removing copy() calls yet because the ShmClientBuffer life time management requires further changes, which I believe, are out of the scope of this patch.

Edited by Vlad Zahorodnii

Merge request reports

Loading