Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 19 Nov 2007 16:23:36 -0500
The language was Bliss, designed in 1969 at CMU. I used it for about 15 years. The
choice was based on the fact that in the original architecture it was designed for,
testing the low-order bit was very efficient, and the decision was that this was also a
platform-independent representation.
Also, some languages only recognize negative integers as true and 0 and positive integers
are false (they check the sign bit). Pascal was such a language in some of its
implementations. Except for those implementations where negative meant false and 0 or
positive meant true. Except on those platforms that had one's complement arithmetic
where there were distinguishable -0 and +0 (I once worked on one where -0 != 0 != +0 !=
+0. Really! The bits were CBA8421M. M was not involved in the tests, C was parity. -0
was B. +0 was CBA. There was a +0 which was A, but it could not be generated by the ALU,
but if seen it was +0. 0 was C. And there was no test that said ==0, because to get this
you had to compare the value to 0, and the -1 and the two +0s were not only unequal to
each other, they were unequal to 0).
This means that each interface must do marshalling of values which are not compatible, but
this is basically a requirement of all interface specifications. Code in the same
language on the same machine is marshalled trivially, everything else is negotiable.
joe
On Mon, 19 Nov 2007 12:33:59 -0000, "Les" <l.neilson@xxxxxxxxxxxxxxxxxxx> wrote:
A real killer comes with mixed language programming (a world in which I haveJoseph M. Newcomer [MVP]
lived for many years) and passing variables, boolean especially, from one
language to another.
Different compilers may have different representations for true/false.
I heard some time ago about a compiler (details unknown) which IIRC
recognised odd integers as "true" and even integers (and zero) as "false"
thus conflicting with another language which only recognised "1" as "true"
and "0" as "false".
This way lies madness Ahahahahahaaaa!
Les
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:rmpsj3p6oeoavqta6i1dlccmsafj67cd96@xxxxxxxxxx
I know that. Back when I was a C programmer in the early 1980s, I defined
boolean.h
typedef int boolean;
#define true 1
#define false 0
Using integer types instead of a boolean type is essentially slopping
programming. This
is in the same class as people writing
int flag;
and then writting
flag = 1;
or
flag = 0;
to change a boolean value. It is habit that too many bad C programmers
seem to develop,
since they learned C from K&R first edition. Since I learned to program
in real languages
that had a boolean type, I decided that using integers to represent
boolean values was a
really stupid idea. I wrote a few C programs in the 1970s, but decided
the language was
apalling. K&R C really was an apalling language. ANSI C was the first
respectable
instance of the language, and C++ is of course much better. But I find
programmers using
the antiquated concept that integers should be used to represent boolean
values even
today.
I consider any compiler that diagnoses while(TRUE) to be worthy of a
warning to be a
compiler that does not understand reality.
joe
On Fri, 16 Nov 2007 05:34:47 -0500, David Wilkinson
<no-reply@xxxxxxxxxxxx> wrote:
Joseph M. Newcomer wrote:Joseph M. Newcomer [MVP]
Perhaps because you asked it to? If you write a computation that
consumes all the CPU, it
is going to, guess what, consume all the CPU! And that's what you've
written! So
presumably you WANT to consume 100% of the available CPU time.
I have no idea what while(1) means anyway. while(TRUE) makes sense;
while(true) makes
sense. What's an integer got to do with it?
Joe:
Well, while(1) and while(TRUE) are in fact the same thing. while(1) is
often used in C where there is no bool type.
I agree that while(true) is preferred, but all these constructs produce
warnings in recent VC versions at level 4 (at least in C++ mode), and
the preferred usage is for(;;). I find this ugly, but have started using
it since I started compiling at level 4.
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Why INFINITE loop in a thread occupy so much CPU time??
- From: lostlander
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: Joseph M . Newcomer
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: David Wilkinson
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: Joseph M . Newcomer
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: Les
- Why INFINITE loop in a thread occupy so much CPU time??
- Prev by Date: Re: GetFontUnicodeRanges() will not compile
- Next by Date: Re: GetFontUnicodeRanges() will not compile
- Previous by thread: Re: Why INFINITE loop in a thread occupy so much CPU time??
- Next by thread: how can i get windows update file list and time
- Index(es):
Relevant Pages
|