Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-15-2016, 05:51 AM   #1
LQ Newbie
Registered: Aug 2015
Posts: 16

Rep: Reputation: Disabled
Smile what is System V semaphores

Hi all,

I am a newbie to a number of technologies here, so i am seeking the kind of answers that are very detailed .

I have a FreeRadius/Postegresql installation that crashed at some point; reason to be that, Postegresql would not start, the error displayed was ...
FATAL: could not create semaphores: No space left on device
(The issue was resolved by increasing the semaphore limits ).

Now, what does it mean exactly
System V semaphores
I googled this a little bit but always this term comes mentioned in some advanced programming context, I would like to understand what does it mean but in the context that i have mentioned above.

Thanks in advance .
Old 08-15-2016, 08:51 AM   #2
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,961
Blog Entries: 12

Rep: Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034Reputation: 2034
Semaphores are a programming concept, not necessarily advanced. The wikipedia page on semaphores overview them well.

The important part there is that there was no space left and by adding higher limits, using more memory for this application, you were able to resolve the problem. Software applications report problems when they run out of available resources or memory, and these reports can vary when you reach system limits.

Other limits in Linux are things like the number of processes or the number of files allowed on a system which can be changed for applications where there are a number of concurrent processes running or if an application needs a number of open files in order to run. In this case, semaphore were being used, which is just another limit.

Therefore another resource to understand are the limits.conf where some of the system maximums are configurable.
1 members found this post helpful.
Old 08-15-2016, 09:03 AM   #3
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,675
Blog Entries: 4

Rep: Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023Reputation: 3023
... and the key rationale for these limits is to avoid, say, "fork()-bombing," whether intentional or accidental. If your innocently buggy program goes into a loop acquiring semaphores or spawning processes or gobbling memory or what-have-you, it must be stopped before it impacts the system as a whole. (And, so that you can recognize that the problem exists(!), and fix it.)
Old 08-15-2016, 10:58 AM   #4
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
Relational data base managers (RDBMS) make use of semaphores (and messages too) to insure that multiple users (or processes) do not clash when updating a table; the idea is the same as semaphores on railroads so that two trains do not use the same section of track at the same time, one waits, the other goes.

You may want to look at any applications you've written to see how many updates are happening at any given time rather than simply increasing the number of semaphores. PostgreSQL handles collisions pretty well (as do MariaDB/MySQL) but it's more or less up to you to do updates serially in your application software. Look to see if you have multiple processes updating the same table at the same time and consider using a single function to do the updates (or inserts or deletes) which will give the DBMS a better chance at not running out of semaphores. Also, if you've use semaphores in your programming but sure that when a semaphore has completed that it release the semaphore so you don't get overflow.

Have a look at what the [I]ipcs/I] utility show you. On a quiescent system (mine) you'll see something like this

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 1443004416 trona      600        393216     2          dest         
0x00000000 1443037185 trona      600        393216     2          dest         
0x00000000 1443069954 trona      600        393216     2          dest         
0x00000000 1443102723 trona      600        393216     2          dest         
0x00000000 1443266564 trona      600        393216     2          dest         
0x00000000 1443495941 trona      600        393216     2          dest         
0x00000000 2010152966 trona      600        393216     2          dest         
0x00000000 2010251271 trona      600        393216     2          dest         
0x00000000 2012446728 trona      600        393216     2          dest         
0x00000000 1448345609 trona      600        524288     2          dest         

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0xcbc384f8 44204035   trona      600        1         

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
Those semaphore arrays are managed by MariaDB in this case -- if you see a whole lot of them, that's a hint to look deeper, and, of course, simply increasing the size of space you need might be the right answer but so may looking into how you are updating from multiple processes.

Hope this helps some.
2 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Implement POSIX Semaphore APIs using System V Semaphores APIs LXer Syndicated Linux News 0 10-16-2012 09:30 AM
Semaphores... newcranium Linux - Server 4 03-29-2011 03:11 AM
[SOLVED] C - Semaphores, initiate semaphores seems to be failing golmschenk Programming 3 06-28-2010 10:32 PM
What is Semaphores? imsajjadali Red Hat 3 04-23-2004 02:26 AM
Semaphores help mojozoox Programming 1 01-07-2004 09:41 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration