LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-15-2016, 04:51 AM   #1
ITareliteralyMyInitials
LQ Newbie
 
Registered: Aug 2015
Posts: 17

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 .

Background:
I have a FreeRadius/Postegresql installation that crashed at some point; reason to be that, Postegresql would not start, the error displayed was ...
Quote:
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
Quote:
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, 07:51 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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, 08:03 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
... 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, 09:58 AM   #4
tronayne
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: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
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
Code:
ipcs

------ 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.
  


Reply



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 08:30 AM
Semaphores... newcranium Linux - Server 4 03-29-2011 02:11 AM
[SOLVED] C - Semaphores, initiate semaphores seems to be failing golmschenk Programming 3 06-28-2010 09:32 PM
What is Semaphores? imsajjadali Red Hat 3 04-23-2004 01:26 AM
Semaphores help mojozoox Programming 1 01-07-2004 08:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:15 AM.

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