473,396 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Synchrionization

I have a critical section and 3 procceses,2 of them can be at the same
time in the section.
I use mutex and doing it the followong way below,but it's not working.

How to make it work or maybe to do it in other way ?? Thank you very
much!

Here is the code:
//Function before the critical section:
// Info is singlecall which is mutual to all classes
Start()
{
Guid index=new Guid();
numberofPro =Info.Instance.numberofPro ;
if(numberOfPro >0)
{
Info.Instance.Mutex.ReleaseMute(Info.Instance.know n_index);
}
index=Info.Instance.Mutex.AskMutex();
numberofPro ++;
Info.Instance.numberofPro =numberofPro;

}

End()
{
int numberofPro = Info.Instance.numberofPro ;
numberofPro--;
Guid index=new Guid(Info.Instance.known_index);
if(numberofPro==0)
{
Info.Instance.Mutex.ReleaseMutex(index);
}
Info.Instance.known_index=numberofPro ;
}

//Function in the end of critical section:

*** Sent via Developersdex http://www.developersdex.com ***
Jan 15 '06 #1
1 1037
Hi,

It is hard to tell if there is something wrong with your code because the
code you posted doesn't show anything about how the mutex is used. What we
see is calling some custom methods e.g
Info.Instance.Mutex.ReleaseMutex(index) and Info.Instance.Mutex.AskMutex();

You should better post a simple compilable sample that demonstrates the
problem that we can easily compile and run.
--

Stoitcho Goutsev (100)

"csharpula csharp" <cs*******@yahoo.com> wrote in message
news:ev*************@TK2MSFTNGP12.phx.gbl...
I have a critical section and 3 procceses,2 of them can be at the same
time in the section.
I use mutex and doing it the followong way below,but it's not working.

How to make it work or maybe to do it in other way ?? Thank you very
much!

Here is the code:
//Function before the critical section:
// Info is singlecall which is mutual to all classes
Start()
{
Guid index=new Guid();
numberofPro =Info.Instance.numberofPro ;
if(numberOfPro >0)
{
Info.Instance.Mutex.ReleaseMute(Info.Instance.know n_index);
}
index=Info.Instance.Mutex.AskMutex();
numberofPro ++;
Info.Instance.numberofPro =numberofPro;

}

End()
{
int numberofPro = Info.Instance.numberofPro ;
numberofPro--;
Guid index=new Guid(Info.Instance.known_index);
if(numberofPro==0)
{
Info.Instance.Mutex.ReleaseMutex(index);
}
Info.Instance.known_index=numberofPro ;
}

//Function in the end of critical section:

*** Sent via Developersdex http://www.developersdex.com ***

Jan 16 '06 #2

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

Similar topics

10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.