473,599 Members | 3,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Semaphore handling

Hello all,

I m facing a memory related problem with semaphores. Our business
application uses semaphores extensively and the limit imposed by the OS
on the number of semaphores that can exist on the system is only 128.

This could be increased to a higher value but that would not be a
permanant solution to my belief. We are using the sem_get, sem_acquire
php functions. After the use we are releasing the semaphore by using
sem_release.

The problem is that the semaphore will remain on the system until it is
rebooted. And once the limit of 128 semaphores is reached, any attemt
to create a new semaphore will result in a "No space left on device"
error.

Can anybody help with any solutions in this regard.

Thanks

Ratheesh K J

Jun 28 '06 #1
5 2512
try sem_remove();
Marek

Unni napsal(a):
Hello all,

I m facing a memory related problem with semaphores. Our business
application uses semaphores extensively and the limit imposed by the OS
on the number of semaphores that can exist on the system is only 128.

This could be increased to a higher value but that would not be a
permanant solution to my belief. We are using the sem_get, sem_acquire
php functions. After the use we are releasing the semaphore by using
sem_release.

The problem is that the semaphore will remain on the system until it is
rebooted. And once the limit of 128 semaphores is reached, any attemt
to create a new semaphore will result in a "No space left on device"
error.

Can anybody help with any solutions in this regard.

Thanks

Ratheesh K J

Jun 28 '06 #2
sem_remove will cause trouble if there are other processes blocking on
the semaphore. This has already been tried.

Is there any way to remove a semaphore only if there are no processes
waiting on it?

I mean to say that if there are processes blocking on the sem then
release the semaphore after use otherwise remove it.

I m in search of the best possible strategy to do this....

Any suggestions?

Thanks
Ratheesh K J

Marek Simon wrote:
try sem_remove();
Marek

Unni napsal(a):
Hello all,

I m facing a memory related problem with semaphores. Our business
application uses semaphores extensively and the limit imposed by the OS
on the number of semaphores that can exist on the system is only 128.

This could be increased to a higher value but that would not be a
permanant solution to my belief. We are using the sem_get, sem_acquire
php functions. After the use we are releasing the semaphore by using
sem_release.

The problem is that the semaphore will remain on the system until it is
rebooted. And once the limit of 128 semaphores is reached, any attemt
to create a new semaphore will result in a "No space left on device"
error.

Can anybody help with any solutions in this regard.

Thanks

Ratheesh K J


Jun 28 '06 #3
1st idea. try to aquire semaphore and remove it only if aquire was
succesfull.
2nd idea. prevent creating new semaphores and reuse the old.
Marek

Ratvin napsal(a):
sem_remove will cause trouble if there are other processes blocking on
the semaphore. This has already been tried.

Is there any way to remove a semaphore only if there are no processes
waiting on it?

I mean to say that if there are processes blocking on the sem then
release the semaphore after use otherwise remove it.

I m in search of the best possible strategy to do this....

Any suggestions?

Thanks
Ratheesh K J

Jun 29 '06 #4
I am not very clear about the 1st idea. The 2nd idea can be looked
into.

At the same time i would like to know whether message queues would help
in synchronization ?

Any suggestions!!!

Thanks,

Ratheesh K J

Marek Simon wrote:
1st idea. try to aquire semaphore and remove it only if aquire was
succesfull.
2nd idea. prevent creating new semaphores and reuse the old.
Marek

Ratvin napsal(a):
sem_remove will cause trouble if there are other processes blocking on
the semaphore. This has already been tried.

Is there any way to remove a semaphore only if there are no processes
waiting on it?

I mean to say that if there are processes blocking on the sem then
release the semaphore after use otherwise remove it.

I m in search of the best possible strategy to do this....

Any suggestions?

Thanks
Ratheesh K J


Jun 29 '06 #5
Marek Simon can u pls tell me what do you exactly intend in that first
idea.

Thanks,

Ratheesh K J

Ratvin wrote:
I am not very clear about the 1st idea. The 2nd idea can be looked
into.

At the same time i would like to know whether message queues would help
in synchronization ?

Any suggestions!!!

Thanks,

Ratheesh K J

Marek Simon wrote:
1st idea. try to aquire semaphore and remove it only if aquire was
succesfull.
2nd idea. prevent creating new semaphores and reuse the old.
Marek

Ratvin napsal(a):
sem_remove will cause trouble if there are other processes blocking on
the semaphore. This has already been tried.
>
Is there any way to remove a semaphore only if there are no processes
waiting on it?
>
I mean to say that if there are processes blocking on the sem then
release the semaphore after use otherwise remove it.
>
I m in search of the best possible strategy to do this....
>
Any suggestions?
>
Thanks
Ratheesh K J
>
Jul 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4345
by: Bastian Hammer | last post by:
Hi I´m wondering why there are so few examples with Semaphore. Is it obsolete? I´ve got a Class Data. It offers 2 Threads methods for updating, editing, .. a private dictionary. Now I have to make sure, that both threads are synchronal,
0
3897
by: dede | last post by:
Dear community, having written a working example for using Semphores on a windows client, I created a little "server-application" that does the following: A Server continously "listens/tails" a command-file for new commands. If a new commands arrives a split of the workload to threads is under- taken that "control themselves" via Semaphore and are joined finally. It works.
1
2638
by: rushik | last post by:
Hello all, I m facing an interesting problem related to semaphore in php. We are using a huge business application running on LAMP. For database operations we are maintaining centralized DB manager classes in php which perform all the single table related activity. Before inserting new record we are acquiring semaphore on specific key (all the tables are having seprate sem keys), insert the record and release the semaphore.
5
4597
by: marvind | last post by:
I tried using a Semaphore class (have included the full listing reproduced from article Figure 1 at the end of this email) in .NET 1.1. It works fine most of the time, however, I see the following error occassionally: 08/28/2005 17:32:42.82, Verbose, QueryObject.MergeSubQuery, Exception: Too many posts were made to a semaphore in mscorlib. Server stack trace:
2
2134
by: techi_C | last post by:
Hi I'm getting a problem while removing semaphore from system. Before removing semaphore I'm checking the usage count of a smaphore. // checking usage count usage_count = semctl(sem_ptr->semid, 1, GETVAL, NULL); if( usage_count 1 ) // return don't remove semaphore else
1
2265
by: cranfic | last post by:
Please help... To make it simple, I have a simple test C program which calls my semphore library functions only. (It doesn't call any db2 function at all). And the following is the test program: #include "hasem.h" #include <semaphore.h> #include <stdio.h>
0
959
by: sukasa | last post by:
Greetings. After first noticing a malfunction in my application, I ran some tests which have given me the following insights on the code performance: -The " infinite" loop which waits on the semaphore first thing in every iteration, may succeed in going through several iterations. -The number of successful iterations may differ with every execution, as well as with timing differences caused by the different placement of breakpoints. ...
0
2240
by: Samuel R. Neff | last post by:
I'm having trouble creating a Semaphore with read-access rights for everyone. Originally I was trying to use this code: semaphore = new Semaphore(maxLocks, maxLocks, "RwLock#" + name); but when using that code to create a Semaphore instance for an existing system semaphore (i.e., the second time the code gets hit), I get an UnauthorizedAccessException. So I tried specifying that everyone has read rights:
5
2717
by: GHUM | last post by:
hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,"stringincludinginterfaceandport") rt=win32event.WaitForSingleObject (hSem, 0) if rt != win32event.WAIT_TIMEOUT: really_do_start_my_app() else:
0
7992
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8398
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8400
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8267
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5438
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3898
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3940
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1505
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.