Re: Heap memory available (W32 console app in Visual C++)
  Home FAQ Contact Sign in
microsoft.public.vc.language only
 
Advanced search
POPULAR GROUPS

more...

microsoft.public.vc.language Profile…
 Up
Re: Heap memory available (W32 console app in Visual C++)         


Author: CriCri
Date: Aug 27, 2008 23:52

CriCri a écrit :
>
> Well if a process stays in a critical section for more than 100ms...

I just looked at some of my own code of 1988.
A quick calculation shows that the longest critical section I found
would have taken less than 10ms on a processeur running at 8MHz (yes, yes).
(I also found some others for a CPU at 20MHz: slightly longer blocks but
faster.)
So I guess that nowadays we could probably say that in general a
critical section lasting even more than 1ms is either looping (badly
written) or malicious.
So that's even better: we are justified in killing it sooner.

(When I get time I will work out an example of how long an average but
very intensive critical section might take on a modern processeur (let's
say from 500MHz to 3GHz - like I generally get in my workshop) and we'll
see how long it would be reasonable to let it continue running.)
Show full article (1.04Kb)
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: Doug Harrison [MVP]
Date: Aug 28, 2008 04:31

On Wed, 27 Aug 2008 17:56:50 +0200, CriCri leTIRETmaquis.net>
wrote:
>Hello Doug
>
>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.
>A mutex is like a token in a token ring: once someone has got it nobody
>else can have it.

It's not a contradiction. 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.
>Has Microsoft redefined what is a 'mutex' too? (is that what your 'pet
>peeve' is?)
Show full article (1.43Kb)
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: Alexander Grigoriev
Date: Aug 28, 2008 04:46

I'm afraid you're requesting a feature, that none of modern general purpose
operating systems implement.

There is no implicit synchronization mechanism for data. Mutex ownership is
just a token. A program "knows" that this particular state should only be
accessed while holding this token. If a program refuses to cooperate and
simply messes with the state without acquiring the "token", then you're
screwed. If the protected state is limited only to your own process, then
you can use CRITICAL_SECTION, which is actually a lightweight mutex.

Global memory availability is not a protected resource. You can ask how much
memory is globally available, and the next microsecond it may be gone.
Moreover, this is different thing than your local virtual address space
availability. While your process address space can only be changed by your
process, there is no guarantee that an allocation request could be
satisfied; precisely beause you can't know global memory availability.

"CriCri" leTIRETmaquis.net> wrote in message
news:48b59fb3$0$913$ba4acef3@news.orange.fr...
> Hello Sven
>
> SvenC a
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: SvenC
Date: Aug 28, 2008 14:06

Hi CriCri,
>> There is no concept of locking an object like G so that automatically
>> all code accessing that object is synchronized.
>
> In my view that is a very fundamental and important design fault in
> these OS.
> The system should track attempts to access global (shared) objects and
> verify that no process holding a mutex is currently accessing them
> _before_ granting access to any other process - whether it has
> requested a mutex or not (and then grant access when the mutex is
> released).
Show full article (1.31Kb)
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: Doug Harrison [MVP]
Date: Aug 29, 2008 04:00

On Thu, 28 Aug 2008 23:39:52 +0200, CriCri leTIRETmaquis.net>
wrote:
>Doug and yourself both want to wash over this imprecision by saying "we
>(Windows programmers), know what we mean: and the rest of you ought to
>be able to understand our interpretation".



In my very first post in this thread, I mentioned a "pet peeve" of mine,
which I said is due to MS misusing standard terminology to name a data
structure (CRITICAL_SECTION) after a piece of code (critical section)
instead of calling it what it is, a type of mutex. Therefore, I find it
laughable that you would now accuse me of essentially making up terms on
the basis of my being a "Windows programmer".

--
Doug Harrison
Visual C++ MVP
6 Comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: Alan Carre
Date: Aug 29, 2008 05:41

"Doug Harrison [MVP]" mvps.org> wrote in message
news:l0meb45dprt2qv6vmk47elu1364pa261ek@4ax.com...
> On Thu, 28 Aug 2008 23:39:52 +0200, CriCri leTIRETmaquis.net>
> wrote:
> In my very first post in this thread, I mentioned a "pet peeve" of mine,
> which I said is due to MS misusing standard terminology to name a data
> structure (CRITICAL_SECTION) after a piece of code (critical section)
> instead of calling it what it is, a type of mutex. Therefore, I find it
> laughable that you would now accuse me of essentially making up terms on
> the basis of my being a "Windows programmer".

Frankly this whole thread is "laughable", though I suppose there are those
that find it amusing to discover ever-more creative ways to say exactly the
same thing, and others just as ready and willing to re-criticize the
rephrasing *even-more* creatively than the last time they criticized it.
Show full article (1.98Kb)
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: Alex Blekhman
Date: Aug 29, 2008 08:46

"Alan Carre" wrote:
> I happen to believe that such redundancy, as demonstrated here,
> can only result as a direct consequence of applying the art of
> something I have never fully understood. Namely: "human
> creativity".

The more trivial is a topic the more "creative" responses are. :)
If you want to see outbursts of creartivity, then just start a
thread

What is more correct: "int* p;" or "int *p;"?

or

Should I write like this

if(blah) {
...
}

or like this
Show full article (0.68Kb)
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: SvenC
Date: Aug 29, 2008 09:15

Hi CriCri,
>> Learn how to use the tools [threading and synchronization
> mechanisms], there is no alternative!
>
> Yes, I've already started learning to work round the limitations!
>
> It just means I will have to charge the customer much more if I get
> another request to 'port' a program which ran for years without any
> problems under MS-DOS to a DOS VM.

How did you do multi threading in MS-DOS?
I think you are confusing preemtive multi threading and
cooperative multi tasking of the old Win 3.x times.
Are you really sure that your port does need multiple threads at
all? If not, drop them to cut your porting costs.
> But maybe I will just tell them to keep a separate physical machine
> and not change anything - it will probably be cheaper.
Show full article (1.44Kb)
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: Alan Carre
Date: Aug 29, 2008 15:46

"Alex Blekhman" yahoo.com> wrote in message
news:eMNacKaCJHA.4340@TK2MSFTNGP02.phx.gbl...
> "Alan Carre" wrote:
> The more trivial is a topic the more "creative" responses are. :) If you
> want to see outbursts of creartivity, then just start a thread
>
> What is more correct: "int* p;" or "int *p;"?
>
> or
>
> Should I write like this
>
> if(blah) {
> ...
> }
>
> or like this
>
> if(blah)
> { ...
Show full article (1.69Kb)
no comments
Re: Heap memory available (W32 console app in Visual C++)         


Author: SvenC
Date: Aug 29, 2008 16:05

Hi Alan,
>> The more trivial is a topic the more "creative" responses are. :) If
>> you want to see outbursts of creartivity, then just start a thread
>>
>> What is more correct: "int* p;" or "int *p;"?
...
> As I said, this property of "human creativity" is still a mystery to
> me, so any known way to force it to occur could provide vital clues
> as to how it actually works.

Find the right question for the answer "42" and you should have
reached the point of understanding just about everything.
Don't hesitate to share your findings with us ;-)

--
SvenC
no comments
1 2 3 4 5 6 7 8 9