Skip to main content

Data structures

MistServer uses POSIX shared memory (or shared files) for Inter Process Communication (IPC). In principle shared memory is the fastest way for multiple processes to communicate large amounts of data between each other. Not all operating systems implement this exactly the same.

Linux

By default linux sets shared memory to 50% of your total RAM and uses tmpfs to implement it. While 50% of RAM is usually plenty, it would be a shame not to be able to use the other half of your RAM if it is a dedicated media server. For this reason MistServer warns upon start up if shared memory is 50% or less of total RAM.

On most distributions you can change this permanently by adding a line in /etc/fstab like this:

tmpfs /dev/shm tmpfs nodev,nosuid,noexec,size=95% 0 0

You can change it (temporarily) in an already running system with following command as root:

mount -o remount,size=95% /dev/shm

MacOs

In MacOS POSIX shared memory is available as well, however it is limited to 4 megabytes total system-wide. Since this is unusable for video data we have opted to use a shared file system for MacOS based systems instead.

The operating system aggressively caches shared files in RAM so in reality performance is on par with shared memory.

Windows

Windows has POSIX shared memory as well and without any limitations. However on Windows it is not possible to detect the size of shared memory objects and there is a peculiarity that the operating system will delete any shared memory object that is no longer in use by any process.

While we have used Windows native shared memory in the past, we found it to be unstable enough that current builds use Cygwin's emulated Linux shared memory implementation. Cygwin effectively uses shared files for this implementation (aggressively caching in RAM), but otherwise it works the same as Linux shared memory.

Data structures

MistServer has the following data structures within shared memory: