Re: Heap memory available (W32 console app in Visual C++)
On Thu, 28 Aug 2008 22:25:58 +0200, CriCri <bitwyse@leTIRETmaquis.net>
wrote:
Doug Harrison [MVP] a ?crit :
On Thu, 28 Aug 2008 19:03:50 +0200, CriCri
<bitwyse@leTIRETmaquis.net> wrote:
Doug Harrison [MVP] a ?crit :
That's the desired result, but it depends completely on the
threads all acquiring the same mutex before entering the
critical section.
Now I just don't understand that statement _at all_! - it's a
contradiction in terms.
It's not a contradiction.
It's the way you expressed it that didn't make any sense.
It makes perfect sense to anyone...
Not at all - it is complete nonsense to everyone.
I quote you without clipping anything anywhere:
"it depends completely on the threads all acquiring the same mutex
before entering the critical section."
The full quote, without any clipping, is:
"That's the desired result, but it depends completely on the threads all
acquiring the same mutex before entering the critical section. No mutex
acquisition, no critical section."
That is the same as saying
"all the threads must acquire the same mutex _before_ any may enter
the critical section" - implying that they must all do so at the same time.
That is the contradiction.
What you just said is wrong, because mutexes don't work like that. It's not
the same as what I said. If you were to map what I said to code, you would
have:
Thread A:
lock(mx);
.... critical section
Thread B:
lock(mx);
.... critical section
Thread C:
lock(mx);
.... critical section
Thread D:
.... not a critical section
I used the word "all" because you seemed to be having problems with the
"cooperation" notion, and I wanted to emphasize that the mutex acquisition
is necessary by all the threads wanting to enter their critical sections.
...who understands what a mutex is, which I gently pointed out in the
remainder of the paragraph, which you clipped:
You did not write that in the message that I criticized, but in a later
one explaining and justifying your original misleading statement; which
implied that YOU didn't understand what a mutex is.
But I did write it immediately after my sentence, "It's not a
contradiction," and it is what you clipped in order to continue arguing.
Every thread that wants to access the shared data has to acquire
the mutex before doing so. If the mutex is currently held by
thread X, another thread Y will block when it tries to acquire
the mutex; that follows from the definition of a mutex.
If you had any genuine doubt about what I meant, that should have cleared
it up for you, and it also demonstrated why someone who understands what a
mutex is cannot reasonably interpret what I said in the way you continue to
do. The final clause established that. If you still don't understand why
this is so, I can't make it any clearer.
--
Doug Harrison
Visual C++ MVP