Autor Beitrag
prebbe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Fr 17.08.07 12:42 
Can i have a critical section inside a critical section?

critical section...
RunAProcedure; <- this also contains a critical section... DOES THAT WORK?
end critical secition
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Fr 17.08.07 12:59 
Hello,

I think it can, but IMHO it is senseless, because if you have started a critical sections it is the once running thread of your programm. If you start in this section an other critical section it doesn't change this state. It means, no other threads will be stopped, because all threads are allready stopped.

yours sincerely
Heiko
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Fr 17.08.07 13:03 
user profile iconHeiko hat folgendes geschrieben:
Hello,

I think it can, but IMHO it is senseless, because if you have started a critical sections it is the once running thread of your programm. If you start in this section an other critical section it doesn't change this state. It means, no other threads will be stopped, because all threads are allready stopped.

yours sincerely
Heiko

Nothing stops, when you enter a critical section! A critical section is an object, that manages a simple state. If you have an object, you need access to from different threads, each thread has to use the CS-object to state that it requires exclusive access to something. What this "something" is, is what you have to define!

So, there is no problem in using multiple CS, as long as you know which CS is for what kind of access and you implement the usage of the required CS in your code.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Fr 17.08.07 13:27 
user profile iconUGrohne hat folgendes geschrieben:
Nothing stops, when you enter a critical section!

Yes ok, I understood apparently MSDN at that time wrongly ;). But you are right.

I have just test to enter two cs with the same cs-"id". It works ;).