When running semget under Linux to create semaphores, it returns – 1 and the creation fails;
1. This function is a system function. You can only confirm the actual error code with errno, print errno through strError, and return no space left on device. Is the system space insufficient? Insufficient space to create semaphores?
2. Go to errno. H to check the error message enospc corresponding to the actual error code. What does this field mean?
3. Does the semget function have its own error field? Check the function manual: check the man Manual of semget function: a semaphore set has to be created but the system limit for the maximum number of semaphore sets (semmni), or the system-wide maximum number of semaphores. Semaphore exceeds system limit.
It is basically determined that it is caused by the system semaphore. First, temporarily modify the kernel semaphore parameters and run again to see whether it has been solved.
4. The following commands are used in viewing semaphores
#1)The sysctl command can view and set system kernel parameters
# The 4 corresponding values from left to right are SEMMSL, SEMMNS, SEMOPM and SEMMNI.
sysctl -a | grep sem #View the setting value of the system semaphore
kernel.sem = 250 32000 32 128
#2) There are three ways to modify: the numbers are for reference only
echo 610 86620 100 142 > /proc/sys/kernel/sem
sysctl -w kernel.sem="610 86620 100 142"
echo "kernel.sem=610 86620 100 142" >> /etc/sysctl.conf`
#3) View the current semaphore and pid of the system as well as user information, view more information and check --help
ipcs -s -p -c
#4) Delete the semaphore method of the specified semid, and check more usage --help
ipcrm -s semid
#5) Delete all semid semaphore methods
ipcrm -asem
5. Here, in the process of finding semaphore resource leakage, in order to facilitate real-time viewing of semaphore information, the semaphore output is written into the script and printed circularly
#ipcs.sh
echo “ipcs -s loop”
while [ 1 ]
do
sleep 1
ipcs -s
done
6. Note: the final problem here is to see why the semaphore in the code exceeds the limit. Normally, the semaphore will not exceed the system limit.
Read More:
- linux C called object ‘maze’ is not a function or function pointer printf(“%d\t“, maze(i, j))
- [Solved] Git Error: OpenSSL SSL_read: Connection was reset, errno 10054和Failed to connect to github.com port 443
- How to Fix xterm Xt error: Can’t open display: xterm: DISPLAY is not set
- [Solved] Flask Error: RuntimeError: The session is unavailable because no secret key was set.
- Git Syntax Error: TypeError: this.getOptions is not a function [How to Solve]
- Git Error Resolution: errno:10054 Time out
- Set the cursor of Ubuntu terminal to turn on automatic display
- How to set fixed IP address for Raspberry Pie
- [Solved] zookeeper Cluster error: Error: JAVA_HOME is not set and java could not be found in PATH.
- [Solved] Your requirements could not be resolved to an installable set of packages.
- How to Solve C++ Error: “no matching function for call to ‘atoi/atof’”
- How to Solve Android Linux5.10 Kernel do_gettimeofday Function Error
- [Solved] ioctl_cfg80211.c:1130:4: error: too many arguments to function ‘cfg80211_roamed’
- [Solved] Readiness probe failed: calico/node is not ready: BIRD is not ready: Error querying BIRD: unable to
- Git-2.16.1.2-64-bit Error: cannot spawn git: Function not implemented
- The JSON variable is parsed in the shell to obtain the value corresponding to the key
- hb set Error: OHOS ERROR] Invalid vendor path: /home/openharmony/vendor (openharmony Compile ubuntu20.04 official document)
- An error occurred during the signature verification in the ROS function pack warehouse
- [Solved] ERROR: The kernel module failed to load, because it was not signed by a key that is trusted by the
- Linux Drive Error: Error: function declaration isn’t a prototype