[英]How to increase the maximum semaphore limit on MacOS/BSD
I want to increase the maximum number of semaphores that can be opened at the same time.我想增加可以同时打开的最大信号量数。
I know that the current limit can be retrieved via我知道可以通过检索当前限制
long nsems_max = sysconf(_SC_SEM_NSEMS_MAX);
or from the console via或从控制台通过
ipcs -S
semmap: 30 (# of entries in semaphore map)
semmni: 8 (# of semaphore identifiers)
semmns: 128 (# of semaphores in system)
semmnu: 0 (# of undo structures in system)
semmsl: 87381 (max # of semaphores per id)
semopm: 5 (max # of operations per semop call)
semume: 10 (max # of undo entries per process)
semusz: 32 (size in bytes of undo structure)
semvmx: 32767 (semaphore maximum value)
semaem: 16384 (adjust on exit max value)
On Linux the limit can be changed by manually editing在 Linux 上,可以通过手动编辑来更改限制
/proc/sys/kernel/sem
but this doesn't work for MacOS/BSD.但这不适用于 MacOS/BSD。 How to change/increase the limit on Mac?
如何更改/增加 Mac 上的限制?
The following variables are editable via /usr/sbin/sysctl
(available for your current session), or you can create a plist to always set the values on reboot.以下变量可通过
/usr/sbin/sysctl
(可用于当前会话)进行编辑,或者您可以创建一个plist以始终在重新启动时设置这些值。 You must create the file.您必须创建该文件。
sudo vi /Library/LaunchDaemons/sysctl.plist`
Set them as your heart desires.随心所欲地设置它们。
/Library/LaunchDaemons/sysctl.plist /Library/LaunchDaemons/sysctl.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>sysctl</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/sysctl</string>
<string>-w</string>
<string>kern.sysv.semmni=87381</string>
<string>kern.sysv.semmns=87381</string>
<string>kern.sysv.semmnu=87381</string>
<string>kern.sysv.semmsl=87381</string>
<string>kern.sysv.semume=10</string>
<string>kern.posix.sem.max=10000</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Then load:然后加载:
launchctl load /Library/LaunchDaemons/sysctl.plist
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.