What causes a "RTIOsapiSharedMemoryMutex_create:OS semget() failure, error 0X1C" error message?

Note: Applies to RTI Connext 4.x.

Problem

Sometimes when you start your RTI Connext application, you get the following error:

[D0037|ENABLE]RTIOsapiSharedMemoryMutex_create:OS semget() failure, error 0X1C 
[D0037|ENABLE]NDDS_Transport_Shmem_create_recvresource_rrEA:failed to initialize shared memory resource mutex for key 0xb04114

Solution

If RTI Connext reports an error that your application was unable to allocate a named semaphore, the problem most likely lies in the number of semaphores available. Your system is running out of available "System V" semaphores for RTI Connext to use for managing shared memory communication. RTI Connext 4.x and above will leave those semaphores around after a ^C and reuse them for later participants with the same index and domain.

Solaris Systems

Each RTI Connext application that has shared memory enabled allocates 2 individual semaphores. The Solaris system defaults allow only 10 per host, which may not be enough (one is often used by the system, so you'll run out at the 5th domain/index combination).

To increase the number of semaphores available to RTI Connext, change the values of the following two parameters in /etc/system. (Starting in Solaris 10, there is an alternate mechanism to control these values, but /etc/system will still work.) The following values are just one possible example: 

set semsys:seminfo_semmni = 100
set semsys:seminfo_semmns = 100

If those parameters already exist in /etc/system, change their values; otherwise, add the lines to your /etc/system file. 

Warning: Please note that changing /etc/system should be done VERY carefully—incorrect editing of the file can render your system unbootable! 

Linux Systems

Each RTI Connext application that has shared memory enabled allocates 2 individual semaphores. The Linux system defaults allow only 128 per host, which may not be enough (one is often used by the system, so you'll run out at the 64th domain/index combination). 

To increase the number of semaphores available to RTI Connext, change the values of semmns and semmni in /etc/sysctl.conf. The following values are just one possible example; they show semmns to be 32000 andsemmni to be 1024: 

# semaphores: semmsl, semmns, semopm, semmni 
kernel.sem = 250 32000 100 1024 

If those parameters already exist in /etc/sysctl.conf, change their values; otherwise, add the lines to your /etc/sysctl.conf file. 

Warning: Please note that changing /etc/sysctl.conf should be done VERY carefully—incorrect editing of the file can render your system unbootable! 
Notes:
"System V" semaphores are allocated by creating groups of individual semaphores. semmni above controls the maximum number of semaphore groups, and semmns controls the maximum total number of semaphores (within any and all groups). 

Each RTI Connext application that has shared memory enabled allocates 2 groups of 1 semaphore each (per domain). That means that setting the two values to be the same would work fine as far as RTI Connext is concerned. However, if other applications in the system want to allocate bigger groups, you could set semmns larger than semmni. (Setting semmni bigger than semmns does not make any sense, since groups can't have less than 1 semaphore.)
Platform: