Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 05-08-2008, 12:10 AM   #1
LQ Newbie
Registered: Mar 2007
Posts: 16

Rep: Reputation: 0
Question Implementing shared/exclusive locking (readers/writer) lock

I am using semaphore to implement Single Writer Multiple Readers (Reader / writer) lock.
The problem is that semaphores are critical resources in linux systems, and there is a limit on the number of semaphores

that you can create.
So, after creating some semaphores, sometimes my application exceeds this limit, and I get an error like 'No space left on


I have to reboot the system sometimes, to release the semaphores, if my application is terminated abruptly!

How should I implement readers/writers lock using something else than semaphore, which is scalable?

I don't need reader/writer locks across multiple processes. I just need to use them in multiple threads of my application,

which is a single process.
But I want a very scalable solution, say I want 500 locks through out my application daemon's lifetime.

I read in the link below that postgres also suffered the same problem, but there it is recommended that the limit should be

increased, which I don't want users to do.


Last edited by ruj.sabya; 05-08-2008 at 12:14 AM.
Old 05-08-2008, 02:23 AM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,396

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
Semaphores are a memory flag, should have nothing to do with disk space (afaik)
Old 05-08-2008, 04:21 AM   #3
LQ Newbie
Registered: Mar 2007
Posts: 16

Original Poster
Rep: Reputation: 0
That is the error you get when you exceed the limit.
That is: ENOSPC (errno 28).


locks, semaphore, semaphores, shared

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot get exclusive lock Enochs Fedora 6 09-16-2007 10:22 AM
Cannot get exclusive lock apokryphos Linux - Newbie 3 12-02-2004 07:22 AM
error: cannot get exclusive lock on /var/lib/rpm/Packages orly Linux - Software 2 09-06-2004 07:13 AM
exclusive lock on cd burning rosscopeeko Red Hat 2 09-01-2003 01:22 PM
exclusive lock on cd burning rosscopeeko Linux - Software 0 08-30-2003 07:39 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:05 PM.

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