eXtremeDB allows two or more processes in a multi-processing operating environment (for example, Linux and Windows platforms) to share a common database.
Overview
In order to share the data between multiple processes, the database must be created in shared memory. Multiple threads within a process share the memory of that process. The shared memory that is used by the eXtremeDB runtime is architecture and operating system dependent. In some environments, the eXtremeDB runtime uses a System V shared memory mechanism (for example, Sun Solaris and Linux) while for others it uses POSIX style shared memory. On Microsoft Windows platforms there is yet another shared memory mechanism. When the database is created, the runtime allocates two shared memory segments: one for the eXtremeDB “registry” that keeps information about all database instances created on the machine, and another segment for the data itself. All database operations are then done via eXtremeDB standard interfaces.
Implementation
eXtremeDB shared memory applications are different in two ways from database applications that use conventional memory:
1) they must link with the shared-memory runtime libraries, and
2) the shared database is opened in only one process while other processes simply connect to it.
The shared-memory libraries are operating system dependent and are explained in detail in the package contents pages.
Shared Memory Runtime Options
The eXtremeDB runtime must be informed of shared memory configuration through runtime options. The shared memory options are OS specific.
For Windows applications
There are two groups of runtime options: one for determining the scope of the shared memory block name (local or global), and one for determining the security level applied to the shared memory block. The combination of options are applied to the name specified in the shared (named) memory block device. Please see the Native Language APIs section for instructions on setting these runtime options for your development environment.
For Linux applications
Linux shared memory applications use the POSIX function
mmap()
to provide mapping of virtual shared memory to a current process. (Seeman
pagehttp://man7.org/linux/man-pages/man2/mmap.2.html
for details). Please see the Native Language APIs section for instructions on setting these runtime options for your development environment.For Unix applications
On Unix systems the shared memory access mode is specified by the Unix specific value of file system access rights. Shared memory and semaphores have the same system of permissions as ordinary files to restrict access by processes of different users and groups. (Unix file access permissions are described here:
https://en.wikipedia.org/wiki/File_system_permissions
).Shared memory on MacOS and some Linux systems
When developing eXtremeDB applications on MacOS it might be necessary to reconfigure system shared memory settings – even for applications that do not intentionally use shared memory. This is because a small amount of shared memory is allocated to processes by default. (Actually, this is not only a Mac problem; some Linux distributions have similar settings by default.)
To resolve this the default shared memory settings should be changed by editing (or creating) file
/etc/sysctl.conf
with the following settings:kern.sysv.shmmax=1073741824 kern.sysv.shmall=262144 kern.sysv.shmmin=1 kern.sysv.shmseg=32 kern.sysv.shmmni=128This allocates up to 1Gb of shared memory to a process. (Please refer to the following article for more details:
http://www.spy-hill.net/help/apple/SharedMemory.html.)
Native Language APIs
The APIs for shared memory applications are specific to the programming language used. Please use the links below to view detailed explanations and examples for your development environment:
C Shared memory applications in C C++ Shared memory applications in C++ Java Shared memory applications in Java Python Shared memory applications in Python C# Shared memory applications in C#