Re: Heap memory available (W32 console app in Visual C++)
On Tue, 26 Aug 2008 22:29:45 +0200, CriCri <bitwyse@leTIRETmaquis.net>
wrote:
You seem to misunderstand how critical sections work. All threads
accessing the same shared data must do so under the same critical
section, otherwise it won't help any. You can't enforce proper access
synchronization from just one thread - all threads must cooperate.
You seem to have a different understanding of "critical sections" from me.
In my terms (as a low-level assembly language programmer, having written
a multi-tasking kernel) the start of a critical section is marked by a
mutex and until it is cleared no other thread can acquire the CPU.
During a critical section the question of co-operation and sharing data
therefore simply doesn't exist: that is the entire point.
Part of the confusion is due to Windows naming its lightweight mutex
"CRITICAL_SECTION", which has been a pet peeve of mine for a long time.
That said, your definition of "critical section" starts off OK, but it goes
a bit awry at the word "CPU". If you were to replace "CPU" with "mutex and
enter the critical section", there wouldn't be any question you understand
the "cooperation" point Igor was raising.
--
Doug Harrison
Visual C++ MVP