Good Morning (afternoon/evening) All,
I am writing some code that explicitly accesses a piece of hardware on the PCI slot. This hardware can only be written to/ read from by one function/process/thread at a time.
Due to the complexity of the program, I can't really put all the read and writes in one function, with an EnterCriticalSection() at the beginning to only allow one calling thread access at a time.
So my question:
Can I use EnterCriticalSection() with the same Critical section object in more than one place? ie:
void SomeFunction()
{
EnterCriticalSection(CritSec);
...do stuff here
LeaveCriticalSection(CritSec);
}
void AnotherFunction()
{
EnterCriticalSection(CritSec);
...do other stuff here
LeaveCriticalSection(CritSec);
}
Will this provide the behaviour I'm after, or am I barking up the wrong tree?
Cheers...
Mark
I am writing some code that explicitly accesses a piece of hardware on the PCI slot. This hardware can only be written to/ read from by one function/process/thread at a time.
Due to the complexity of the program, I can't really put all the read and writes in one function, with an EnterCriticalSection() at the beginning to only allow one calling thread access at a time.
So my question:
Can I use EnterCriticalSection() with the same Critical section object in more than one place? ie:
void SomeFunction()
{
EnterCriticalSection(CritSec);
...do stuff here
LeaveCriticalSection(CritSec);
}
void AnotherFunction()
{
EnterCriticalSection(CritSec);
...do other stuff here
LeaveCriticalSection(CritSec);
}
Will this provide the behaviour I'm after, or am I barking up the wrong tree?
Cheers...
Mark