Ancient_Hacker said:
Flash said:
I'm not up on all the latest portability poop, but isnt there something
called "POSIX", and "POSIX-threads?". aka /IEEE 1003/ , ISO/IEC 9945.
That is only to POSIX systems. The last time I checked, which was using
the current versions of Windows and my subscription to MSDN which
provides the latest compiler version etc, POSIX threads were not part of
Windows.
... not the best solution, IMHO, as you're adding considerable system
load and page faulting to start up a shell, which will start up "who"
or "top". Adding two more processes and load to the mix might
obfuscate just what we want to know. Not to mention running any
system command is non portable, which somehow is okay for you to
blithely do, but gets my butt kicked around in an infinite loop.
Just before the bit you left in I said:
| I know for a fact you can find out the *real* information because on
| the common systems because there are lots of programs that actually
| report it. Something that sounds far easier to me.
The implication I was making, which you seem to have missed, was that
you can do what I have stated more than once in this thread and use some
system specific routine to do it. The bit you left in was just a silly
example showing that it can be done with far less code than the masses
that you are ending up with.
I stated my solution was not portable. Yours was not portable yet you
keep trying to claim it is. It also has the one and only advantage I
claim for it, being far simpler than yours to implement and using far
less system specific routines.
How's about we try to focus on intelligently answering the OP's
question, instead of trying to convince each other what *has* been done
can't be done to some particular level of purity?
I have already answered that more than once. Ask in a system specific
group for the correct system specific way to get the information.
To repeat the point you are continuing to fail to address and snipped
from my last post:
| So you are using at least two system specific routines. Why not
| actually ask the OS for the information in a system specific manner
| since you *are* doing system specific things anyway
Especially since once you have added in all the other system specific
bits to get your solution close to working required at least half a
dozen system specific things.
I honestly can't understand why you think that anything other than
asking the OS for the CPU utilisation would be appropriate when the OS
can give you accurate information with the overhead of a single hook to
the OS + any initial one off setup it requires. Any other method will be
less accurate, more complex (as illustrated by your attempts to work
around all of the problems I've raised with you "solution" not all of
which you've addressed"), requires more code, will waist more processing
time, and be less efficient by any measure I can think of.
I really cannot think why, having had it pointed out to you that it is
possible to ask the OS for the information, you cannot accept it as a
vastly superior solution.
No, I'm not going to post the solution here because it would not be
properly vetted. I've just looked up in the MS documentation to prove to
myself (not you) that I am correct in what I've said all along that
there is a proper system specific solution.
Now, unless you are going to address this point I've raised repeatedly
I'll just file you under the category of troll and only respond to you
where required to point out that you are giving bad advice if others
have not beaten me to it.