function myobj(){
var gup=this;
this.lastindex=-1;
this.criticalSectionInTimer=0;
this.updateTimer;
this.start = function(l){
if((typeof this.updateTimer)=="number"){
clearInterval ( this.updateTimer );
}
this.updateTimer=setInterval(function() {gup.getMessages();} , 30);
}
this.stop= functio...
Is semaphore an IPC mechanism?
...
Hi everyone:
This is my first attempt on semaphores and threads.
I constructed this code from examples and the man pages found on the Net.
I have two doubts with this code.
Why do I get a Bus error whenever I try semctl( I know this is the root of the problem because of the debug line 3 does not get printed) and how to prevent it?
Wh...
I am using following code to limit use of resources.
Once in a while(after 3-4 days of successful run) I get queue empty exception or the returned object is found to be null.
I am wondering if I am limiting only 5 threads to enter this Get method, how come this happens.
The places where GetConnection is called, ReleaseConnection is al...
I'm experiencing a lot of difficulty getting Semaphores to work on a Linux based system in C.
The process of my application is such:
Application starts
Application forks into child/parent
Each process uses sem_open with a common name to open the semaphore.
If I create the semaphore before forking, it works fine. However, requiremen...
I have been studying internals of Java for quite some time. I am curious to learn and understand how threading/locking takes place in Java.
So, in order to access a synchronized method or a synchronized block, the thread has to acquire the lock on the object first. So, now, here is what I need a bit more light.
So, whenever the thread...
Hi,
This is the reader-writer problem for just read consistency.
Here is the algorithm,
void reader() {
while (1){
P(mutex);
rc++;
if (rc == 1) P(db); /* <---- A */
V(mutex); /* <---- B */
read_data_base();
P(mutex):
rc--;
V(mutex);
if (rc ==0) V(db);
}
...
I've heard these words related to concurrent programming, but what's the difference between them?
...
Throughout the resources I've read about multithreading, mutex is more often used and discussed compared to a semaphore. My question is when do you use a semaphore over a mutex? I don't see semaphores in Boost thread. Does that mean semaphores no longer used much these days?
As far as I've understand, semaphores allow a resource to be s...
(In short: main()'s WaitForSingleObject hangs in the program below).
I'm trying to write a piece of code that dispatches threads and waits for them to finish before it resumes. Instead of creating the threads every time, which is costly, I put them to sleep. The main thread creates X threads in CREATE_SUSPENDED state.
The synch is done...
I have multiple threads that share use of a semaphore. Thread A holds the semaphore (using lock) and threads B and C are waiting on that same semaphore (also using lock). The threads share global variables, etc.
Is there a technique in C# that I can use to shut down thread B? I can set a flag in A and have thread B check that flag and...
Ferryboats go back and forth, carrying passengers from one side of the canal to the
other. Each boat can hold at most C passengers. The passengers wait for the boats to
ferry them across the canal. A boat can start crossing the river only when it is full. A
boat cannot start loading passengers on one side of the canal if another boat is ...
I have a Semaphore that runs trough a list of Job objects.
Here is a sample of the code:
List<Job> jobList = jobQueue.GetJobsWithStatus(status);
if (jobList.Count > 0)
{
foreach (Job job in jobList)
{
semaphore.WaitOne();
// Only N threads can get here at once
job.semaphore = semaphore;
ThreadStart threadStart = ne...
JI have written a .NET C# Windows Form app in Visual Studio 2008 that uses a Semaphore to run multiple jobs as threads when the Start button is pressed.
It’s experiencing an issue where the Form goes into a comma after being run for 40 minutes or more. The log files indicate that the current jobs complete, it picks a new job from the li...
I am trying to create a Win32 Semaphore object which is inheritable. This means that any child processes I launch may automatically have the right to act on the same Win32 object.
My code currently looks as follows:
Semaphore semaphore = new Semaphore(0, 10);
Process process = Process.Start(pathToExecutable, arguments);
But the sem...
I have a queue structure that is being used by several pthreads. The threads are supposed to dequeue from the queue if it's not empty and then do their business.
I initially had this set up as a while loop where the threads checked whether the queue was empty using a mutex_lock. Unfortunately this slowed my program down to a crawl.
I t...
The documentation for the .NET Semaphore class states that:
There is no guaranteed order, such as FIFO or LIFO, in which blocked threads enter the semaphore.
In this case, if I want a guaranteed order (either FIFO or LIFO), what are my options? Is this something that just isn't easily possible? Would I have to write my own Semaph...
Hi
In previous question of mine, someone had meantioned that using Semaphores were expensive in C# compared to using a monitor. So I ask this, how can I replace the semaphore in this code with a monitor?
I need function1 to return its value after function2 (in a separate thread) has been completed. I had replaced the Semaphore.WaitOne ...
You know we can use message queues with the function mq_receive(); what is a good way to implement that functionality (you know, waiting until the shared data is changed) with semaphores?
...
Hallo i need to install and libs for c.I am using a linux ubuntu o/s.Does anybody knows how i can install them?
...