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.M utex.ReleaseMut e(Info.Instance .known_index);
}
index=Info.Inst ance.Mutex.AskM utex();
numberofPro ++;
Info.Instance.n umberofPro =numberofPro;
}
End()
{
int numberofPro = Info.Instance.n umberofPro ;
numberofPro--;
Guid index=new Guid(Info.Insta nce.known_index );
if(numberofPro= =0)
{
Info.Instance.M utex.ReleaseMut ex(index);
}
Info.Instance.k nown_index=numb erofPro ;
}
//Function in the end of critical section:
*** Sent via Developersdex http://www.developersdex.com ***
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.M utex.ReleaseMut e(Info.Instance .known_index);
}
index=Info.Inst ance.Mutex.AskM utex();
numberofPro ++;
Info.Instance.n umberofPro =numberofPro;
}
End()
{
int numberofPro = Info.Instance.n umberofPro ;
numberofPro--;
Guid index=new Guid(Info.Insta nce.known_index );
if(numberofPro= =0)
{
Info.Instance.M utex.ReleaseMut ex(index);
}
Info.Instance.k nown_index=numb erofPro ;
}
//Function in the end of critical section:
*** Sent via Developersdex http://www.developersdex.com ***
Comment