Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Even bytes get lonely for a little bit.


devel / comp.arch / Paper about ISO C

SubjectAuthor
* Paper about ISO Cclamky
+- Re: Paper about ISO CBGB
+* Re: Paper about ISO CDavid Brown
|+* Re: Paper about ISO CBGB
||+* Re: Paper about ISO CMitchAlsup
|||+* Re: Paper about ISO CMitchAlsup
||||`* Re: Paper about ISO CBranimir Maksimovic
|||| `* Re: Paper about ISO CGeorge Neuner
||||  +- Re: Paper about ISO CBranimir Maksimovic
||||  `* Re: Paper about ISO CEricP
||||   `* Re: Paper about ISO CIvan Godard
||||    `* Re: Paper about ISO CEricP
||||     `* Re: Paper about ISO CMitchAlsup
||||      +* Re: Paper about ISO CBGB
||||      |`* Re: Paper about ISO CStephen Fuld
||||      | +* Re: Paper about ISO CIvan Godard
||||      | |+* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | ||+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |||+- Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |||+* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | ||||`- Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | |||`- Re: addressing and protection, was Paper about ISO CBill Findlay
||||      | ||`* Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | || +- Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | || `- Re: addressing and protection, was Paper about ISO CBranimir Maksimovic
||||      | |`* Re: addressing and protection, was Paper about ISO CEricP
||||      | | +* Re: addressing and protection, was Paper about ISO CStefan Monnier
||||      | | |`- Re: addressing and protection, was Paper about ISO CEricP
||||      | | `* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  |+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  ||`* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  || `* Re: addressing and protection, was Paper about ISO CJohn Dallman
||||      | |  ||  +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  ||  |+- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  |+* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  ||  ||`* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  || `* Re: addressing and protection, was Paper about ISO CAnton Ertl
||||      | |  ||  ||  `- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  |`* Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | |  ||  | +- Re: addressing and protection, was Paper about ISO CQuadibloc
||||      | |  ||  | `- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  ||  `- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  |`* Re: addressing and protection, was Paper about ISO CJohn Dallman
||||      | |  | +* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |`* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | | `* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |  |+* Re: addressing and protection, was Paper about ISO CStefan Monnier
||||      | |  | |  ||+- Re: addressing and protection, was Paper about ISO CChris M. Thomasson
||||      | |  | |  ||+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |  |||`- Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  ||+* Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  |||`* Re: addressing and protection, was Paper about ISO CEricP
||||      | |  | |  ||| `- Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |  ||`- Re: addressing and protection, was Paper about ISO CJohn Dallman
||||      | |  | |  |`- Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |  `* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |   +- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |   `* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |    +* Address space consumption (was: addressing and protection, was Paper about ISO CStefan Monnier
||||      | |  | |    |`- Re: Address space consumption (was: addressing and protection, wasMitchAlsup
||||      | |  | |    +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |    |`- Re: addressing and protection, was Paper about ISO CThomas Koenig
||||      | |  | |    `* Re: addressing and protection, was Paper about ISO CGeorge Neuner
||||      | |  | |     `* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |      +* Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |      |`* Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |      | `- Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |      `* Re: addressing and protection, was Paper about ISO CStefan Monnier
||||      | |  | |       +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       |`* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |  | |       | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |`* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |       | | `* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |  `* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |  | |       | |   +- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |   +- Re: addressing and protection, was Paper about ISO Cclamky
||||      | |  | |       | |   `* Re: addressing and protection, was Paper about ISO CGeorge Neuner
||||      | |  | |       | |    +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    |`* Re: addressing and protection, was Paper about ISO CGeorge Neuner
||||      | |  | |       | |    | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | |+* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |       | |    | ||+* Re: educational computation, was addressing and protection, was Paper about ISO John Levine
||||      | |  | |       | |    | |||`* Re: educational computation, was addressing and protection, was PaperIvan Godard
||||      | |  | |       | |    | ||| `- Re: educational computation, was addressing and protection, was PaperTerje Mathisen
||||      | |  | |       | |    | ||`* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | || `* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | ||  +- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | ||  `- Re: addressing and protection, was Paper about ISO CDavid Brown
||||      | |  | |       | |    | |+- Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | |`* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | | |+- Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |       | |    | | |`* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | | | +* Re: addressing and protection, was Paper about ISO CIvan Godard
||||      | |  | |       | |    | | | |+* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    | | | ||`- Re: addressing and protection, was Paper about ISO CJimBrakefield
||||      | |  | |       | |    | | | |`* Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |       | |    | | | | `* Re: addressing and protection, was Paper about ISO CTim Rentsch
||||      | |  | |       | |    | | | |  `- Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |       | |    | | | +* Re: addressing and protection, was Paper about ISO CBGB
||||      | |  | |       | |    | | | `- Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | |       | |    | | `- Re: addressing and protection, was Paper about ISO CAnne & Lynn Wheeler
||||      | |  | |       | |    | `- Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | |       | |    `* Re: what is cheap these days, addressing and protection, was Paper about ISO CJohn Levine
||||      | |  | |       | +* Re: addressing and protection, was Paper about ISO CStephen Fuld
||||      | |  | |       | +* Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |       | `* Re: addressing and protection, was Paper about ISO CMichael S
||||      | |  | |       +* RAM size (was: addressing and protection, was Paper about ISO C)Anton Ertl
||||      | |  | |       `- Re: addressing and protection, was Paper about ISO CTerje Mathisen
||||      | |  | +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  | `* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | |  +* Re: addressing and protection, was Paper about ISO CMitchAlsup
||||      | |  `* Re: addressing and protection, was Paper about ISO CJohn Levine
||||      | `* Re: Paper about ISO CBGB
||||      `- Re: Paper about ISO CEricP
|||+* Re: Paper about ISO CBranimir Maksimovic
|||+* Re: Paper about ISO CThomas Koenig
|||+* Re: Paper about ISO Cantispam
|||`- Re: Paper about ISO CQuadibloc
||+* Re: Paper about ISO CThomas Koenig
||`* Re: Paper about ISO CDavid Brown
|+* Re: Paper about ISO CThomas Koenig
|`* Re: Paper about ISO CVictor Yodaiken
`* Re: Paper about ISO CKent Dickey

Pages:123456789101112131415161718192021222324252627282930313233
Paper about ISO C

<87fstdumxd.fsf@hotmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20738&group=comp.arch#20738

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.mixmin.net!aioe.org!xcrumNapWYKcczN4Ruh1Kw.user.46.165.242.75.POSTED!not-for-mail
From: cla...@hotmail.com
Newsgroups: comp.arch
Subject: Paper about ISO C
Date: Thu, 07 Oct 2021 13:52:30 +0300
Organization: Aioe.org NNTP Server
Message-ID: <87fstdumxd.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="33778"; posting-host="xcrumNapWYKcczN4Ruh1Kw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:QUhnSaNd0WZI8mACimIhdLQtILE=
 by: cla...@hotmail.com - Thu, 7 Oct 2021 10:52 UTC

Might strike a cord with Anton and/or Mich

https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/

Re: Paper about ISO C

<sjneps$gfv$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20739&group=comp.arch#20739

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 7 Oct 2021 13:37:47 -0500
Organization: A noiseless patient Spider
Lines: 192
Message-ID: <sjneps$gfv$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Oct 2021 18:37:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3c4f404c3f5da9215fe0005020ce92fe";
logging-data="16895"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XKa0FqYt8e1GPfErv2wLc"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.1.2
Cancel-Lock: sha1:CTcHoRXC6cBEt4udZ9JNwGqCrMc=
In-Reply-To: <87fstdumxd.fsf@hotmail.com>
Content-Language: en-US
 by: BGB - Thu, 7 Oct 2021 18:37 UTC

On 10/7/2021 5:52 AM, clamky@hotmail.com wrote:
> Might strike a cord with Anton and/or Mich
>
> https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/
>

I am a little less strict on this topic, but my general opinion is that
things like strict aliasing should be "opt in" rather than "opt out".

But, yeah, the guy who wrote that in-general has a point, but also tends
to be a bit overly alarmist IMO about these issues.

For example, consider a case of caching struct loads, there are multiple
approaches:
1, Always do the load (my compiler did this originally);
2, Cache, but only within a single basic-block, flush on store (current
rule);
3, Cache, invalidate entries on store if matching types (strict aliasing);
4, Assume that no aliasing occurs whatsoever (playing with fire).

I have noted experimentally that 2 can gain a fair bit of speedup over
1, and is pretty much invisible within a single thread.

The 3 option is closer to what GCC and Clang do by default, but I opt
against this by default given it is unsafe. Doom and Quake and similar
still work with this option. It also seems to be only modestly faster
than 2.

The 4 option is unsafe; it is a little faster than 3 at Dhrystone, but
Doom and Quake are prone to crash if one uses this option.

A variation of this optimization has also been applied to array loads.

My preference is also that things like signed integer operations remain
sign modulo (as well as unsigned operations being unsigned modulo), that
signed right shift behaves in the usually-expected ways (arithmetic
shift), ...

So, ideally, one can try to optimize things in that don't turn into
semantic quicksand, even if this means skipping over some possible types
of optimizations.

Similarly, corner cutting is acceptable in cases where the expected
results can be reasonably well-defined, or are "basically invisible"
within reasonable use-cases.

For example, there can be a fairly significant cost difference between
"FPU that implements IEEE-754 correctly", and one that gives answers
that are "more or less correct".

Expensive FPU:
Separate FPU registers (arguably less register pressure);
FADD, FSUB, FMUL, FDIV, FSQRT, FMAC, ...
Always +/- 0.5 ULP;
Implements Denormals;
...

Cheaper FPU:
Reuse integer registers;
FADD, FSUB, FMUL;
Relaxed rounding;
Denormal as Zero;
...

For most programs, the difference between the cheap and expensive FPU is
not noticeable; and the sorts of workloads which "actually care" are
unlikely to be run on a processor that is too cheap to be able to afford
the fancier FPU (and where the relative slowness of doing everything
with software emulation is undesirable).

One might find that a more useful property though, is not so much that
the FPU is accurate, so much that things like "Single->Double->Single"
conversions can be done while keeping the original value intact.

Compiler optimization is an ongoing challenge though.

Most have been fixing various issues, recent notable bug fixes:
Binary operators needlessly converting arguments to the destination type;
Type conversion operators doing operations via unnecessary temporaries;
Unsigned loads using redundant zero-extension ops;
....

An, some sorts of partially addressed issues:
Temporaries always spilling to stack even when the value is no longer
needed (tried to add 'phi' operators to the IR, but this was a fail; did
add logic though for "don't bother storing temporary if it is never
reloaded" which also helps, but is less fine-grained than a 'phi' would
have been).

Had recently (briefly) gotten Dhrystone up to ~ 65k, but it has since
dropped to 63k, seems very sensitive to code-generation options. This is
on my custom ISA at 50MHz, so ~ 0.74 DMIPS/MHz.

While, conceivably, one can push it a little closer to ~0.78 via strict
aliasing, I don't consider this worthwhile ATM.

This seems to be in the sort of intermediate area between "slow" and
"fast" cores (though, not yet figured out what is the nature of the
dividing line). Though, having looked briefly at the SweRV core, I have
noted that they deal with the pipeline in a very different way (for
example, they seem to handle load/store with a queue and interlocks,
rather than running the L1 D$ in lockstep with the pipeline and stalling
the pipeline for each L1 miss).

It does seem like this could be a possible way to improve the speed of a
core, but would introduce its own complexities. I am not sure if this
accounts for a lot of the differences I am seeing (but, in
testing/models, the core is dumping a lot of its clock-cycles into cache
misses, and in theory this could at least help here, if it could be done
cheaply enough).

Though, as can also be noted in my case, my CPU core lacks an integer
divider, and only provides a 32-bit integer multiplier. A full 64-bit
multiplier would be slow and/or expensive. Generally, faking it as an
instruction-blob has been "fast enough".

Pretending to have instructions, but faking them with traps, is the
worst of both worlds (pointless and slow), at least a runtime call to an
ASM function can be reasonable.

I did recently fiddle around with seeing if I could make the ASM code
for integer divide faster, where options are:
Binary Long Division (current mainline option);
Lookup table of reciprocals (sorta works);
Lookup table + shifted-reciprocal (didn't win).

I had recently tried switching from solely using long division as the
default, to using a lookup table with long-division as a fallback. This
is a little faster for small divisors, but a little slower for divisors
that fall out of range of the table. It also adds the cost of the lookup
table (trades logic for cache misses). It also uses up space, and so
favors a fairly small lookup table (under 1K), where for
divide-intensive code the table will mostly fit in the L1 cache.

Shifted reciprocal can extend the range of such a small lookup table to
cover the entire integer range, but comes with a big issue:
The result is not integer exact;
In effect, the error is proportional to the relative size of the input
values.

So, it is fast for things like 3D rendering calculations where one
doesn't really care if the result is integer exact, but for C's "a/b"
operator, being integer exact is mandatory.

The problem then becomes that in many cases, trying to fix this ends up
costing more than had one just used the long division loop.

Most of the workarounds tend to be "maybe helps, maybe makes it worse".

However, most other code doesn't lean quite so heavily on integer divide
performance, so it is usually isn't quite as relevant.

I am hesitant about adding an instruction for IDIV, as for years even
fairly high end x86 CPU lines were plagued with an IDIV instruction
which was slower than doing it in software, and which performance would
likely have been better had the C compilers just called a runtime
function and done the binary long division in the C library.

Including the divide instruction in an ISA carries a non-trivial risk of
such a thing happening again (if compilers decide to use it by default
because "hey, there is an instruction for it, and dedicated instruction
implies fast, right?...").

But, in some sense, it is easier to use special case mechanisms to make
a runtime call faster, than it is to avoid a potential significant
overhead from emulating instructions which don't exist in hardware.

Granted, a possible intermediate option could be to have an instruction
whose dedicated purpose is to call into a location in a table while also
doing two register moves, ..., which then branches to the appropriate
runtime function (sorta like a special GOT mostly for stuff that was too
expensive to add to the ISA directly, but where one kinda wants to
pretend that a CPU instructions exists).

Then one can just sort of declare that all the scratch registers will be
left in an undefined state following the operation.

....

Re: Paper about ISO C

<sjni60$97d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20740&group=comp.arch#20740

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 7 Oct 2021 21:35:27 +0200
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <sjni60$97d$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Oct 2021 19:35:28 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="97e7585a624c44ee9e2a0c6dccdb8439";
logging-data="9453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19A0HG6J9aWN2eJZzprJM0Wym3zuzNSMhg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:MMVPS7aWgCFZQ7mHHRPRh2EibO8=
In-Reply-To: <87fstdumxd.fsf@hotmail.com>
Content-Language: en-GB
 by: David Brown - Thu, 7 Oct 2021 19:35 UTC

On 07/10/2021 12:52, clamky@hotmail.com wrote:
> Might strike a cord with Anton and/or Mich
>
> https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/
>

It seems to me that the authors have misunderstood the language entirely.

C was never meant to be a "high-level assembler" or a "portable
assembler". It was never intended that you could write low-level
systems programs in portable C. It was designed to reduce the need to
write code in assembler, and to improve the portability of code.
(Re-read that sentence if you like.) It was intended to be useable for
writing some kinds of code in a highly portable manner, and also to be
useful in non-portable systems code that depended strongly on the target
and the compiler.

From day one, operating systems "written in C" contained assembly code,
compiler extensions, and other non-portable code. That remains true
today. "Coding tricks" were often used to get efficient results due to
more limited compilers - these are much less common now as compilers
optimise better.

As I got further in the document, it seems to be just another "the
compiler should do what I want it to do, not necessarily what I /told/
it to do" rant. "C today should work the way /I/ want it to do - the
way /I/ interpret the precise wording of what someone decades ago".
"Thompson and Ritchie were saints and prophets, and their words were
holy and eternal - regardless of how computers, languages, and
programming needs have changed since the inception of C". "We were all
happy and no bugs existed in code until gcc sinned by optimising code,
and we were thrown out of Eden into a hell of undefined behaviour".
"Yes, we know that compilers often give us ways to get the semantics we
want by specific flags, but that's not good enough - everyone else
should get slower code so that we don't have to think as much or follow
the rules of the language".

Are there imperfections in C as a language standard? Sure. Show me a
perfect language standard as an alternative. Are there questionable
judgements in some of the design decisions of C toolchains? Sure -
again, show me a perfect toolchain. Is C not quite an exact fit for all
your needs for writing an OS? Sure. It's a general purpose language
that is good for a very wide range of uses - but it's unlikely to be
/perfect/ for any given use-case. And it never has been, and it never
will be. Nor will anything else. Modern C is a vastly better language
than the earliest K&R C. Modern C toolchains are vastly better than the
tools of that era. As well as the hundred steps forward, there have no
doubt been a dozen steps backwards for some people and some uses.
That's life. If you don't like it, give up programming and stick to a
safer hobby.

(For the record, I don't think type-based alias analysis actually gives
very significant optimisation opportunities in most code. On the other
hand, I also don't think it causes problems very often - not nearly as
often as the "optimisation is evil" crowd seem to behave. I write
low-level code all the time, and it is extraordinarily rarely that I
have to find a way around it.)

Re: Paper about ISO C

<sjnmcp$630$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20741&group=comp.arch#20741

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Thu, 7 Oct 2021 15:47:19 -0500
Organization: A noiseless patient Spider
Lines: 145
Message-ID: <sjnmcp$630$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Oct 2021 20:47:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3c4f404c3f5da9215fe0005020ce92fe";
logging-data="6240"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18K8z58au2OW2qHvNG7dWdJ"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.1.2
Cancel-Lock: sha1:YouMaKZescn4B8a9m+dPymfP7qE=
In-Reply-To: <sjni60$97d$1@dont-email.me>
Content-Language: en-US
 by: BGB - Thu, 7 Oct 2021 20:47 UTC

On 10/7/2021 2:35 PM, David Brown wrote:
> On 07/10/2021 12:52, clamky@hotmail.com wrote:
>> Might strike a cord with Anton and/or Mich
>>
>> https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/
>>
>
> It seems to me that the authors have misunderstood the language entirely.
>
> C was never meant to be a "high-level assembler" or a "portable
> assembler". It was never intended that you could write low-level
> systems programs in portable C. It was designed to reduce the need to
> write code in assembler, and to improve the portability of code.
> (Re-read that sentence if you like.) It was intended to be useable for
> writing some kinds of code in a highly portable manner, and also to be
> useful in non-portable systems code that depended strongly on the target
> and the compiler.
>
> From day one, operating systems "written in C" contained assembly code,
> compiler extensions, and other non-portable code. That remains true
> today. "Coding tricks" were often used to get efficient results due to
> more limited compilers - these are much less common now as compilers
> optimise better.
>
>
> As I got further in the document, it seems to be just another "the
> compiler should do what I want it to do, not necessarily what I /told/
> it to do" rant. "C today should work the way /I/ want it to do - the
> way /I/ interpret the precise wording of what someone decades ago".
> "Thompson and Ritchie were saints and prophets, and their words were
> holy and eternal - regardless of how computers, languages, and
> programming needs have changed since the inception of C". "We were all
> happy and no bugs existed in code until gcc sinned by optimising code,
> and we were thrown out of Eden into a hell of undefined behaviour".
> "Yes, we know that compilers often give us ways to get the semantics we
> want by specific flags, but that's not good enough - everyone else
> should get slower code so that we don't have to think as much or follow
> the rules of the language".
>

The author of the paper (Victor Yodaiken) has sort of a long history of
"making a mountain out of a molehill" about all this stuff...

I have my opinions, but will note that "the system" is self-regulating
to some extent, as compiler people would have a hard-time keeping people
using their compilers if they set out to break large amounts of existing
"real world" code (and will tend to back down when they face sufficient
backlash).

In cases where stuff has broken in more significant ways, it has usually
been fairly isolated (a particular build of a particular compiler),
rather than a long-term change to the status quo.

>
> Are there imperfections in C as a language standard? Sure. Show me a
> perfect language standard as an alternative. Are there questionable
> judgements in some of the design decisions of C toolchains? Sure -
> again, show me a perfect toolchain. Is C not quite an exact fit for all
> your needs for writing an OS? Sure. It's a general purpose language
> that is good for a very wide range of uses - but it's unlikely to be
> /perfect/ for any given use-case. And it never has been, and it never
> will be. Nor will anything else. Modern C is a vastly better language
> than the earliest K&R C. Modern C toolchains are vastly better than the
> tools of that era. As well as the hundred steps forward, there have no
> doubt been a dozen steps backwards for some people and some uses.
> That's life. If you don't like it, give up programming and stick to a
> safer hobby.
>

>
> (For the record, I don't think type-based alias analysis actually gives
> very significant optimisation opportunities in most code. On the other
> hand, I also don't think it causes problems very often - not nearly as
> often as the "optimisation is evil" crowd seem to behave. I write
> low-level code all the time, and it is extraordinarily rarely that I
> have to find a way around it.)
>

Will agree on this point.

In my own testing, basic caching while also aggressively invalidating
the cached results (on any explicit memory store), can give much of the
same performance benefit, while still being fairly conservative
semantically.

The problem though is when optimizations start being treated as "all or
nothing", eg, "you either accept TBAA or can't use optimizations at
all", which is a problem IMO.

Say:
x=foo->x;
*ptr=3;
y=foo->x; //Do we reuse prior result here?

Under TBAA, the second "foo->x" may reuse the result of the first, but
under more conservative semantics, the "*ptr=" would effectively
invalidate the cached result regardless of the pointer type.

Whereas, say:
x=foo->bar->x;
y=foo->bar->y;
Becomes, effectively:
t0=foo->bar;
x=t0->x;
y=t0->y;

Where no invalidation happens because local variables don't count as
stores (it is generally pretty safe to assume that local variables exist
off in their own space, roughly entirely independent from physical
memory, unless their address is taken).

One option is to specify subsets of optimizations based on settings, say:
Os, optimize for size (take slower options if smaller);
O1, optimize for speed, favoring size minimization over speed;
O2, optimize for speed, favoring speed over size;
O3, optimize for speed, enable more aggressive optimizations.

So, for example, with Os, O1, and O2, TBAA is not used, whereas for O3
or similar, things like TBAA would be enabled (with secondary options to
enable or disable TBAA semantics).

MSVC does something vaguely similar to this, though from what I have
found, for some types of programs (such as my emulators), O1 tends to be
faster than O2 (I suspect because MSVC's O2 option is a lot more prone
to make use of "misguided attempts at autovectorization" when compared
with O1).

Granted, arguably I could upgrade MSVC and see if anything is
difference, but given I am kinda battling with space on "C:\" (and there
is no real way to make it bigger), not particularly inclined to do so.

Eg, "320GB should be more than enough space for anyone."
Windows: "Nope!"
Me: "Can you at least give me an option to expand the partition?"
Windows: "What sort of insanity is this?..."

Still have space on other drives, but this isn't of much use if one
wants to install another version of Visual Studio or similar.

....

Re: Paper about ISO C

<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20745&group=comp.arch#20745

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:518d:: with SMTP id kl13mr4852563qvb.14.1633653987257;
Thu, 07 Oct 2021 17:46:27 -0700 (PDT)
X-Received: by 2002:a05:6808:2191:: with SMTP id be17mr14490281oib.30.1633653987053;
Thu, 07 Oct 2021 17:46:27 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Thu, 7 Oct 2021 17:46:26 -0700 (PDT)
In-Reply-To: <sjnmcp$630$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:ec77:5d4:3f50:5858;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:ec77:5d4:3f50:5858
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <sjnmcp$630$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Fri, 08 Oct 2021 00:46:27 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 95
 by: MitchAlsup - Fri, 8 Oct 2021 00:46 UTC

On Thursday, October 7, 2021 at 3:47:23 PM UTC-5, BGB wrote:
> On 10/7/2021 2:35 PM, David Brown wrote:
> > On 07/10/2021 12:52, cla...@hotmail.com wrote:
> >> Might strike a cord with Anton and/or Mich
> >>
> >> https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/
> >>
> >
>
> Under TBAA, the second "foo->x" may reuse the result of the first, but
> under more conservative semantics, the "*ptr=" would effectively
> invalidate the cached result regardless of the pointer type.
>
> Whereas, say:
> x=foo->bar->x;
> y=foo->bar->y;
> Becomes, effectively:
> t0=foo->bar;
> x=t0->x;
> y=t0->y;
<
In Operating System code; if one write the top 2 statements, one should
get at least 4 loads--it is simply UNSAFE to assume otherwise--even
if x happens to be allocated into a register (which may happen FAR after
aliasing analysis is performed.)
<
If the programmer KNOWS that there is no aliasing going on, the programmer
should write the bottom set of code.
<
If the programmer writes the top code and expects some kind of compiler
flags (or magic) can translate it to the bottom--the programmer should be
FIRED !
<
Those are the only 3 options available in Operating system code.
You do not allow IDIOTS to write such code and expect anything good to become
of your investment.
>
> Where no invalidation happens because local variables don't count as
> stores (it is generally pretty safe to assume that local variables exist
> off in their own space, roughly entirely independent from physical
> memory, unless their address is taken).
>
>
> One option is to specify subsets of optimizations based on settings, say:
> Os, optimize for size (take slower options if smaller);
> O1, optimize for speed, favoring size minimization over speed;
> O2, optimize for speed, favoring speed over size;
> O3, optimize for speed, enable more aggressive optimizations.
<
Operating systems are in a position where normal codes are not--they have
their own address space and visibility into another address space (or more).
The MMU tables can map multiple virtual addresses to a single physical page.
Are you going to make the compiler smart enough to understand that kind
of memory accessing ??!!?? No, you are not, because it is an unsolvable
problem (outside of SAS.)
>
> So, for example, with Os, O1, and O2, TBAA is not used, whereas for O3
> or similar, things like TBAA would be enabled (with secondary options to
> enable or disable TBAA semantics).
>
If an Operating system wants certain things to run really fast, then embed
this stuff in a library call and optimize the heck out of it (so long as it does
not cross the multipleVA->onePA problem domain.) Then call these optimum
functions from way less optimized code--And here is an Ideal location to
point out that if you inline the optimizable code into unoptimizable code
"text" that inlined function has to take on the unoptimizability of the original
library call.
<
It is much like handling fiearms::
<
1) all pointers are loaded at all times unless verified they are not.
2) never point a pointer at something you do not want destroyed.
3) never enable a pointer until your sights are on the target
<
4) There is NO SUCH THING as a casual pointer.
>
> MSVC does something vaguely similar to this, though from what I have
> found, for some types of programs (such as my emulators), O1 tends to be
> faster than O2 (I suspect because MSVC's O2 option is a lot more prone
> to make use of "misguided attempts at autovectorization" when compared
> with O1).
>
>
> Granted, arguably I could upgrade MSVC and see if anything is
> difference, but given I am kinda battling with space on "C:\" (and there
> is no real way to make it bigger), not particularly inclined to do so.
>
> Eg, "320GB should be more than enough space for anyone."
> Windows: "Nope!"
> Me: "Can you at least give me an option to expand the partition?"
> Windows: "What sort of insanity is this?..."
>
> Still have space on other drives, but this isn't of much use if one
> wants to install another version of Visual Studio or similar.
>
> ...

Re: Paper about ISO C

<967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20746&group=comp.arch#20746

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:66c7:: with SMTP id a190mr540617qkc.427.1633656168877;
Thu, 07 Oct 2021 18:22:48 -0700 (PDT)
X-Received: by 2002:a05:6808:1a11:: with SMTP id bk17mr5968522oib.0.1633656168595;
Thu, 07 Oct 2021 18:22:48 -0700 (PDT)
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Thu, 7 Oct 2021 18:22:48 -0700 (PDT)
In-Reply-To: <ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:ec77:5d4:3f50:5858;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:ec77:5d4:3f50:5858
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me> <ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com>
Subject: Re: Paper about ISO C
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Fri, 08 Oct 2021 01:22:48 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 19
 by: MitchAlsup - Fri, 8 Oct 2021 01:22 UTC

On Thursday, October 7, 2021 at 7:46:28 PM UTC-5, MitchAlsup wrote:
<
You see, here is the dilemma::
<
Assume 2 OS threads, the first in service of a trap from thread[t],
The second in service of a trap from thread[h].
<
OS[t] creates a pointer into thread[t]. Can this pointer be used in any
meaningful way in OS[h] ?
<
No (99.99%) of the time. The lower ½ of OS[t] address space is completely
unrelated to the lower ½ of OS[h] address space--even though 100% of the
upper ½ address space is shared between OS[t] and OS[h]!
<
Can compiler aliasing analysis figure any of this out ?
<
Doubtful !!

Re: Paper about ISO C

<hiN7J.53059$3p3.5024@fx16.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20750&group=comp.arch#20750

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
Newsgroups: comp.arch
From: branimir...@icloud.com (Branimir Maksimovic)
Subject: Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 44
Message-ID: <hiN7J.53059$3p3.5024@fx16.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 08 Oct 2021 01:38:21 UTC
Organization: usenet-news.net
Date: Fri, 08 Oct 2021 01:38:21 GMT
X-Received-Bytes: 2183
 by: Branimir Maksimovic - Fri, 8 Oct 2021 01:38 UTC

On 2021-10-08, MitchAlsup <MitchAlsup@aol.com> wrote:
> On Thursday, October 7, 2021 at 3:47:23 PM UTC-5, BGB wrote:
>> On 10/7/2021 2:35 PM, David Brown wrote:
>> > On 07/10/2021 12:52, cla...@hotmail.com wrote:
>> >> Might strike a cord with Anton and/or Mich
>> >>
>> >> https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/
>> >>
>> >
>>
>> Under TBAA, the second "foo->x" may reuse the result of the first, but
>> under more conservative semantics, the "*ptr=" would effectively
>> invalidate the cached result regardless of the pointer type.
>>
>> Whereas, say:
>> x=foo->bar->x;
>> y=foo->bar->y;
>> Becomes, effectively:
>> t0=foo->bar;
>> x=t0->x;
>> y=t0->y;
><
> In Operating System code; if one write the top 2 statements, one should
> get at least 4 loads--it is simply UNSAFE to assume otherwise--even
> if x happens to be allocated into a register (which may happen FAR after
> aliasing analysis is performed.)
><
> If the programmer KNOWS that there is no aliasing going on, the programmer
> should write the bottom set of code.
><
> If the programmer writes the top code and expects some kind of compiler
> flags (or magic) can translate it to the bottom--the programmer should be
> FIRED !

Isn't it that GC are always advertised as way to solve *cycling references*?

>> ...

--

7-77-777
Evil Sinner!
with software, you repeat same experiment, expecting different results...

Re: Paper about ISO C

<jlN7J.12573$fZ.8007@fx06.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20751&group=comp.arch#20751

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx06.iad.POSTED!not-for-mail
Newsgroups: comp.arch
From: branimir...@icloud.com (Branimir Maksimovic)
Subject: Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
<967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com>
User-Agent: slrn/1.0.3 (Darwin)
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Lines: 33
Message-ID: <jlN7J.12573$fZ.8007@fx06.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 08 Oct 2021 01:41:35 UTC
Organization: usenet-news.net
Date: Fri, 08 Oct 2021 01:41:35 GMT
X-Received-Bytes: 1923
 by: Branimir Maksimovic - Fri, 8 Oct 2021 01:41 UTC

On 2021-10-08, MitchAlsup <MitchAlsup@aol.com> wrote:
> On Thursday, October 7, 2021 at 7:46:28 PM UTC-5, MitchAlsup wrote:
><
> You see, here is the dilemma::
><
> Assume 2 OS threads, the first in service of a trap from thread[t],
> The second in service of a trap from thread[h].
><
> OS[t] creates a pointer into thread[t]. Can this pointer be used in any
> meaningful way in OS[h] ?
><
> No (99.99%) of the time. The lower ½ of OS[t] address space is completely
> unrelated to the lower ½ of OS[h] address space--even though 100% of the
> upper ½ address space is shared between OS[t] and OS[h]!
>
Isn't it that threads are defined as sharing same address space, unlike
processes? Actually there is no other difference between processes and
threads...

<
> Can compiler aliasing analysis figure any of this out ?
><
> Doubtful !!
>
Compiler is nothing, just distraction, buggy assumptions at that...
But you have to know bugs of compilers in order to use them :P

--

7-77-777
Evil Sinner!
with software, you repeat same experiment, expecting different results...

Re: Paper about ISO C

<sjom96$9nv$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20755&group=comp.arch#20755

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 05:51:34 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sjom96$9nv$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
Injection-Date: Fri, 8 Oct 2021 05:51:34 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:2fa2:0:7285:c2ff:fe6c:992d";
logging-data="9983"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 8 Oct 2021 05:51 UTC

BGB <cr88192@gmail.com> schrieb:

> Say:
> x=foo->x;
> *ptr=3;
> y=foo->x; //Do we reuse prior result here?
>
Depends on the type of ptr, if it agrees with foo.x or not.
If both are (for example) *int, then it is not possible to
reuse it. If foo.x is *float and ptr is *unsigned int, then
yes.

Re: Paper about ISO C

<sjomcf$9nv$2@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20756&group=comp.arch#20756

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 05:53:19 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sjomcf$9nv$2@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
Injection-Date: Fri, 8 Oct 2021 05:53:19 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:2fa2:0:7285:c2ff:fe6c:992d";
logging-data="9983"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 8 Oct 2021 05:53 UTC

MitchAlsup <MitchAlsup@aol.com> schrieb:

> It is much like handling fiearms::
><
> 1) all pointers are loaded at all times unless verified they are not.
> 2) never point a pointer at something you do not want destroyed.
> 3) never enable a pointer until your sights are on the target
><
> 4) There is NO SUCH THING as a casual pointer.

I _love_ that.

Re: Paper about ISO C

<sjoo12$9vc$2@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20758&group=comp.arch#20758

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 06:21:22 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sjoo12$9vc$2@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
Injection-Date: Fri, 8 Oct 2021 06:21:22 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:2fa2:0:7285:c2ff:fe6c:992d";
logging-data="10220"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 8 Oct 2021 06:21 UTC

David Brown <david.brown@hesbynett.no> schrieb:
> "We were all
> happy and no bugs existed in code until gcc sinned by optimising code,
> and we were thrown out of Eden into a hell of undefined behaviour".

*snarf*

That was the sound of that qoute hitting the gcc bugzilla quip file.

Re: Paper about ISO C

<c0nvlg9c4v1u2m4t9601rb02u7i6g1b3pg@4ax.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20759&group=comp.arch#20759

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: gneun...@comcast.net (George Neuner)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 08 Oct 2021 02:34:56 -0400
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <c0nvlg9c4v1u2m4t9601rb02u7i6g1b3pg@4ax.com>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <sjnmcp$630$1@dont-email.me> <ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com> <967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com> <jlN7J.12573$fZ.8007@fx06.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="1c542d628a964cea2eaacbdf03b1644c";
logging-data="21108"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Xh9ynIKawxG70w/G7o1kUsVyExQJqRSU="
User-Agent: ForteAgent/8.00.32.1272
Cancel-Lock: sha1:57aqpB/OV+SD7qagCp8IQv9SWK0=
 by: George Neuner - Fri, 8 Oct 2021 06:34 UTC

On Fri, 08 Oct 2021 01:41:35 GMT, Branimir Maksimovic
<branimir.maksimovic@icloud.com> wrote:

>On 2021-10-08, MitchAlsup <MitchAlsup@aol.com> wrote:
>> On Thursday, October 7, 2021 at 7:46:28 PM UTC-5, MitchAlsup wrote:
>><
>> You see, here is the dilemma::
>><
>> Assume 2 OS threads, the first in service of a trap from thread[t],
>> The second in service of a trap from thread[h].
>><
>> OS[t] creates a pointer into thread[t]. Can this pointer be used in any
>> meaningful way in OS[h] ?
>><
>> No (99.99%) of the time. The lower ½ of OS[t] address space is completely
>> unrelated to the lower ½ of OS[h] address space--even though 100% of the
>> upper ½ address space is shared between OS[t] and OS[h]!
>>
>Isn't it that threads are defined as sharing same address space, unlike
>processes? Actually there is no other difference between processes and
>threads...

That's a de facto definition rather than a canon one. Technically
both "process" and "thread" are execution contexts, and they mean
whatever they are defined to mean in a given system. The idea that a
process represents an address space / protection domain while a thread
represents a code path is really only an artifact of the way in which
threads initially were implemented.

As a counter example, consider that on the Mill multiple threads in
the same program simultaneously can be in different protection
domains.

Take a look at "scheduler activations" for a different idea of how the
kernel can support multiple threads.
https://homes.cs.washington.edu/~tom/pubs/sched_act.pdf
http://web.mit.edu/nathanw/www/usenix/freenix-sa/freenix-sa.html

Note: scheduler activations initially may /look/ similar to M:N
threading (userspace threads multiplexed on kernel threads), but
underneath they are quite different.

>> Can compiler aliasing analysis figure any of this out ?
>><
>> Doubtful !!
>>
>Compiler is nothing, just distraction, buggy assumptions at that...
>But you have to know bugs of compilers in order to use them :P

Re: Paper about ISO C

<sjor60$27b$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20760&group=comp.arch#20760

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cr88...@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 02:15:10 -0500
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <sjor60$27b$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me> <sjom96$9nv$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Oct 2021 07:15:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f0ddb7ac7f1187fdac2f4cd61f20676a";
logging-data="2283"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vNPDxgEq/KaBo3micmTmD"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.1.2
Cancel-Lock: sha1:IVWW29GIWUY5e74zcFO5mkaRy9U=
In-Reply-To: <sjom96$9nv$1@newsreader4.netcologne.de>
Content-Language: en-US
 by: BGB - Fri, 8 Oct 2021 07:15 UTC

On 10/8/2021 12:51 AM, Thomas Koenig wrote:
> BGB <cr88192@gmail.com> schrieb:
>
>> Say:
>> x=foo->x;
>> *ptr=3;
>> y=foo->x; //Do we reuse prior result here?
>>
> Depends on the type of ptr, if it agrees with foo.x or not.
> If both are (for example) *int, then it is not possible to
> reuse it. If foo.x is *float and ptr is *unsigned int, then
> yes.
>

I left this part deliberately vague, but yeah.
Under type-based aliasing rules, that would be correct.

I took a more conservative interpretation here by default, and made my
compiler assume that aliasing may occur regardless of any of the actual
types involved.

This gets much of the performance advantage, without a lot of the
potential drawbacks of full strict-aliasing semantics (such as it
interfering with the ability to cast whatever pointer to whatever type
and then perform operations on it).

Re: Paper about ISO C

<sjpasg$a6f$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20763&group=comp.arch#20763

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 13:43:12 +0200
Organization: A noiseless patient Spider
Lines: 231
Message-ID: <sjpasg$a6f$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 8 Oct 2021 11:43:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="747e27c5905b57615cabb4adc19381e0";
logging-data="10447"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gTberuOKQGVnK2VJEHG3zEtQLxYdYK/o="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:D9KKRbGjfVFQmDB0MsYSpR8ZoEs=
In-Reply-To: <sjnmcp$630$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Fri, 8 Oct 2021 11:43 UTC

On 07/10/2021 22:47, BGB wrote:
> On 10/7/2021 2:35 PM, David Brown wrote:
>> On 07/10/2021 12:52, clamky@hotmail.com wrote:
>>> Might strike a cord with Anton and/or Mich
>>>
>>> https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/
>>>
>>>
>>
>> It seems to me that the authors have misunderstood the language entirely.
>>
>> C was never meant to be a "high-level assembler" or a "portable
>> assembler".  It was never intended that you could write low-level
>> systems programs in portable C.  It was designed to reduce the need to
>> write code in assembler, and to improve the portability of code.
>> (Re-read that sentence if you like.)  It was intended to be useable for
>> writing some kinds of code in a highly portable manner, and also to be
>> useful in non-portable systems code that depended strongly on the target
>> and the compiler.
>>
>>  From day one, operating systems "written in C" contained assembly code,
>> compiler extensions, and other non-portable code.  That remains true
>> today.  "Coding tricks" were often used to get efficient results due to
>> more limited compilers - these are much less common now as compilers
>> optimise better.
>>
>>
>> As I got further in the document, it seems to be just another "the
>> compiler should do what I want it to do, not necessarily what I /told/
>> it to do" rant.  "C today should work the way /I/ want it to do - the
>> way /I/ interpret the precise wording of what someone decades ago".
>> "Thompson and Ritchie were saints and prophets, and their words were
>> holy and eternal - regardless of how computers, languages, and
>> programming needs have changed since the inception of C".  "We were all
>> happy and no bugs existed in code until gcc sinned by optimising code,
>> and we were thrown out of Eden into a hell of undefined behaviour".
>> "Yes, we know that compilers often give us ways to get the semantics we
>> want by specific flags, but that's not good enough - everyone else
>> should get slower code so that we don't have to think as much or follow
>> the rules of the language".
>>
>
> The author of the paper (Victor Yodaiken) has sort of a long history of
> "making a mountain out of a molehill" about all this stuff...
>

It seems that way. Often there are some good points - as I wrote, no
language or tool is perfect, and it's important that people find weak
points or make suggestions for improvement. Massively exaggerated
rants, however, are worse than useless - they encourage other fanatics
who feed on the same myths, doom-saying and exaggerations. And they
ensure that those who actually have a say in the tools and language -
the standards committees and compiler developers - will ignore all their
concerns and write them off as fanatics. Good points they raise get
thrown out and ignored along with the reams of rubbish,
misunderstandings and misrepresentations that hide them.

>
> I have my opinions, but will note that "the system" is self-regulating
> to some extent, as compiler people would have a hard-time keeping people
> using their compilers if they set out to break large amounts of existing
> "real world" code (and will tend to back down when they face sufficient
> backlash).

Agreed. Compiler writers have no interest in making tools that people
don't want to use. If feedback suggests a new compiler version does not
work the way people expect and want, then the compiler developers take
that seriously - they discuss matters with the users, they change the
behaviour of the tools, they add flags or options to give users more
control of the behaviour. In particular, they aim to test out new
changes during pre-release and beta test stages so that potential
problems get handled sooner.

A similar process applies to language standards - there are long periods
of proposals, discussions, and voting before changes are made. Big
compiler users (like Linux distributions, corporations such as IBM,
Microsoft, Google), big compiler implementers, researchers, and anyone
else who is interested can get involved and share their opinion.

You are never going to please everyone all of the time. And you are
never going to please the small but vocal community who object to
everything and accuse compiler writers and/or language committees of all
sorts of evil motives and conspiracies. But they do a solid job
overall, which is why languages like C are still a good choice for a lot
of tasks.

>
> In cases where stuff has broken in more significant ways, it has usually
> been fairly isolated (a particular build of a particular compiler),
> rather than a long-term change to the status quo.
>

And usually a "significant break" is found during testing stages, rather
than post release.

>>
>> Are there imperfections in C as a language standard?  Sure.  Show me a
>> perfect language standard as an alternative.  Are there questionable
>> judgements in some of the design decisions of C toolchains?  Sure -
>> again, show me a perfect toolchain.  Is C not quite an exact fit for all
>> your needs for writing an OS?  Sure.  It's a general purpose language
>> that is good for a very wide range of uses - but it's unlikely to be
>> /perfect/ for any given use-case.  And it never has been, and it never
>> will be.  Nor will anything else.  Modern C is a vastly better language
>> than the earliest K&R C.  Modern C toolchains are vastly better than the
>> tools of that era.  As well as the hundred steps forward, there have no
>> doubt been a dozen steps backwards for some people and some uses.
>> That's life.  If you don't like it, give up programming and stick to a
>> safer hobby.
>>
>
>>
>> (For the record, I don't think type-based alias analysis actually gives
>> very significant optimisation opportunities in most code.  On the other
>> hand, I also don't think it causes problems very often - not nearly as
>> often as the "optimisation is evil" crowd seem to behave.  I write
>> low-level code all the time, and it is extraordinarily rarely that I
>> have to find a way around it.)
>>
>
> Will agree on this point.
>
> In my own testing, basic caching while also aggressively invalidating
> the cached results (on any explicit memory store), can give much of the
> same performance benefit, while still being fairly conservative
> semantically.
>

There is a move towards "providence tracking" for memory and pointers as
an alternative to things like type-based alias analysis. This is a lot
more powerful, as it tracks when different references to the same type
cannot alias, and thus can give much more optimisation opportunities and
static error analysis benefits. It subsumes most TBAA, since pointers
to different types usually have different providences. But in cases
where the providence is actually the same, aliases (or potential
aliases) are handled correctly. However, it turns out to be quite
difficult to specify all this, and it is a work in progress (both for
language standards and implementations).

> The problem though is when optimizations start being treated as "all or
> nothing", eg, "you either accept TBAA or can't use optimizations at
> all", which is a problem IMO.
>
> Say:
>   x=foo->x;
>   *ptr=3;
>   y=foo->x;  //Do we reuse prior result here?
>
> Under TBAA, the second "foo->x" may reuse the result of the first, but
> under more conservative semantics, the "*ptr=" would effectively
> invalidate the cached result regardless of the pointer type.
>
> Whereas, say:
>   x=foo->bar->x;
>   y=foo->bar->y;
> Becomes, effectively:
>   t0=foo->bar;
>   x=t0->x;
>   y=t0->y;
>
> Where no invalidation happens because local variables don't count as
> stores (it is generally pretty safe to assume that local variables exist
> off in their own space, roughly entirely independent from physical
> memory, unless their address is taken).
>
>
> One option is to specify subsets of optimizations based on settings, say:
>   Os, optimize for size (take slower options if smaller);
>   O1, optimize for speed, favoring size minimization over speed;
>   O2, optimize for speed, favoring speed over size;
>   O3, optimize for speed, enable more aggressive optimizations.
>
> So, for example, with Os, O1, and O2, TBAA is not used, whereas for O3
> or similar, things like TBAA would be enabled (with secondary options to
> enable or disable TBAA semantics).
>


Click here to read the complete article
Re: Paper about ISO C

<sjpb9c$d03$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20764&group=comp.arch#20764

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!news.niel.me!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 13:50:04 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <sjpb9c$d03$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjoo12$9vc$2@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Oct 2021 11:50:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="747e27c5905b57615cabb4adc19381e0";
logging-data="13315"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oiXQ3WQXhDukfixTiO+WkwIfXeNFeLPo="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:MtgQvnXfUzRb549o0kdw/Y4mzKo=
In-Reply-To: <sjoo12$9vc$2@newsreader4.netcologne.de>
Content-Language: en-GB
 by: David Brown - Fri, 8 Oct 2021 11:50 UTC

On 08/10/2021 08:21, Thomas Koenig wrote:
> David Brown <david.brown@hesbynett.no> schrieb:
>> "We were all
>> happy and no bugs existed in code until gcc sinned by optimising code,
>> and we were thrown out of Eden into a hell of undefined behaviour".
>
> *snarf*
>
> That was the sound of that qoute hitting the gcc bugzilla quip file.
>

I hope you didn't attribute it as a real quotation from the referenced
paper!

(And I hope I didn't offend anyone with some of the imagery I used.)

Re: Paper about ISO C

<_uW7J.29661$IO1.13426@fx19.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20765&group=comp.arch#20765

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx19.iad.POSTED!not-for-mail
Newsgroups: comp.arch
From: branimir...@icloud.com (Branimir Maksimovic)
Subject: Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
<967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com>
<jlN7J.12573$fZ.8007@fx06.iad> <c0nvlg9c4v1u2m4t9601rb02u7i6g1b3pg@4ax.com>
User-Agent: slrn/1.0.3 (Darwin)
Lines: 21
Message-ID: <_uW7J.29661$IO1.13426@fx19.iad>
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Fri, 08 Oct 2021 12:06:18 UTC
Organization: usenet-news.net
Date: Fri, 08 Oct 2021 12:06:18 GMT
X-Received-Bytes: 1573
 by: Branimir Maksimovic - Fri, 8 Oct 2021 12:06 UTC

On 2021-10-08, George Neuner <gneuner2@comcast.net> wrote:
> As a counter example, consider that on the Mill multiple threads in
> the same program simultaneously can be in different protection
> domains.
>
> Take a look at "scheduler activations" for a different idea of how the
> kernel can support multiple threads.
> https://homes.cs.washington.edu/~tom/pubs/sched_act.pdf
> http://web.mit.edu/nathanw/www/usenix/freenix-sa/freenix-sa.html
>
> Note: scheduler activations initially may /look/ similar to M:N
> threading (userspace threads multiplexed on kernel threads), but
> underneath they are quite different.
>
Thanks, I'll look into it.

--

7-77-777
Evil Sinner!
with software, you repeat same experiment, expecting different results...

Re: Paper about ISO C

<sjpcsa$opt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20767&group=comp.arch#20767

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 05:17:13 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <sjpcsa$opt$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me> <sjpasg$a6f$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Oct 2021 12:17:14 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d1d272887b4bad0d5b4c01b0d56b7f5e";
logging-data="25405"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CvcWliRs39OG4aB8fApJM"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:EJ93YTbtNXylZlLQwokyel1gwPs=
In-Reply-To: <sjpasg$a6f$1@dont-email.me>
Content-Language: en-US
 by: Ivan Godard - Fri, 8 Oct 2021 12:17 UTC

On 10/8/2021 4:43 AM, David Brown wrote:

>
> There is a move towards "providence tracking" for memory and pointers as
> an alternative to things like type-based alias analysis. This is a lot
> more powerful, as it tracks when different references to the same type
> cannot alias, and thus can give much more optimisation opportunities and
> static error analysis benefits. It subsumes most TBAA, since pointers
> to different types usually have different providences. But in cases
> where the providence is actually the same, aliases (or potential
> aliases) are handled correctly. However, it turns out to be quite
> difficult to specify all this, and it is a work in progress (both for
> language standards and implementations).

provenance?

Re: Paper about ISO C

<sjpec8$b1t$1@z-news.wcss.wroc.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20768&group=comp.arch#20768

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!gandalf.srv.welterde.de!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 12:42:48 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 79
Message-ID: <sjpec8$b1t$1@z-news.wcss.wroc.pl>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <sjnmcp$630$1@dont-email.me> <ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1633696968 11325 156.17.86.1 (8 Oct 2021 12:42:48 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Fri, 8 Oct 2021 12:42:48 +0000 (UTC)
Cancel-Lock: sha1:KxvvMwcWvNJSbqZGrbrBC+cAZas=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
 by: antis...@math.uni.wroc.pl - Fri, 8 Oct 2021 12:42 UTC

MitchAlsup <MitchAlsup@aol.com> wrote:
> On Thursday, October 7, 2021 at 3:47:23 PM UTC-5, BGB wrote:
> > On 10/7/2021 2:35 PM, David Brown wrote:
> > > On 07/10/2021 12:52, cla...@hotmail.com wrote:
> > >> Might strike a cord with Anton and/or Mich
> > >>
> > >> https://www.yodaiken.com/2021/10/06/plos-2021-paper-how-iso-c-became-unusable-for-operating-system-development/
> > >>
> > >
> >
> > Under TBAA, the second "foo->x" may reuse the result of the first, but
> > under more conservative semantics, the "*ptr=" would effectively
> > invalidate the cached result regardless of the pointer type.
> >
> > Whereas, say:
> > x=foo->bar->x;
> > y=foo->bar->y;
> > Becomes, effectively:
> > t0=foo->bar;
> > x=t0->x;
> > y=t0->y;
> <
> In Operating System code; if one write the top 2 statements, one should
> get at least 4 loads--it is simply UNSAFE to assume otherwise--even
> if x happens to be allocated into a register (which may happen FAR after
> aliasing analysis is performed.)

Sorry, code _assuming_ aliasing there is simply insane, regardless
if this in operating system on not. If anybody really needs
aliansing in such context this should be done by special purpose
construct.

> If the programmer KNOWS that there is no aliasing going on, the programmer
> should write the bottom set of code.
> <
> If the programmer writes the top code and expects some kind of compiler
> flags (or magic) can translate it to the bottom--the programmer should be
> FIRED !
> <
> Those are the only 3 options available in Operating system code.
> You do not allow IDIOTS to write such code and expect anything good to become
> of your investment.

Code as above is typical result of macro expansion (or inlining).
_Depending_ on optimization for any specific use is unwise. But
most systems are written to get good _average_ performance and
in large systems optimization makes difference to average
performance.

> > Where no invalidation happens because local variables don't count as
> > stores (it is generally pretty safe to assume that local variables exist
> > off in their own space, roughly entirely independent from physical
> > memory, unless their address is taken).
> >
> >
> > One option is to specify subsets of optimizations based on settings, say:
> > Os, optimize for size (take slower options if smaller);
> > O1, optimize for speed, favoring size minimization over speed;
> > O2, optimize for speed, favoring speed over size;
> > O3, optimize for speed, enable more aggressive optimizations.
> <
> Operating systems are in a position where normal codes are not--they have
> their own address space and visibility into another address space (or more).
> The MMU tables can map multiple virtual addresses to a single physical page.
> Are you going to make the compiler smart enough to understand that kind
> of memory accessing ??!!?? No, you are not, because it is an unsolvable
> problem (outside of SAS.)

In normal compiler it is compiler who allocates local and global variables
and they are allocated from different memory pool than dynamic memory.
OS that messes with compiler locals is simply insane. OS that plays
tricks with global variables arguably should do this using special
constructs known to compiler (like memory barries, volatile etc.).
Compiler normally are rather conservative in their assumprions about
dynamically allocated memory. So OS that invalidates compiler
assumptions is simply badly designed OS.
--
Waldek Hebisch

Re: Paper about ISO C

<sjpigf$17r$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20769&group=comp.arch#20769

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 15:53:19 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <sjpigf$17r$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me> <sjpasg$a6f$1@dont-email.me>
<sjpcsa$opt$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 8 Oct 2021 13:53:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="747e27c5905b57615cabb4adc19381e0";
logging-data="1275"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jz8mZLvghWLoQoiCp3fcX8nDC78goE24="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:Slu9A1qVVyyOT3UHPOOWiMI7xuc=
In-Reply-To: <sjpcsa$opt$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Fri, 8 Oct 2021 13:53 UTC

On 08/10/2021 14:17, Ivan Godard wrote:
> On 10/8/2021 4:43 AM, David Brown wrote:
>
>
>>
>> There is a move towards "providence tracking" for memory and pointers as
>> an alternative to things like type-based alias analysis.  This is a lot
>> more powerful, as it tracks when different references to the same type
>> cannot alias, and thus can give much more optimisation opportunities and
>> static error analysis benefits.  It subsumes most TBAA, since pointers
>> to different types usually have different providences.  But in cases
>> where the providence is actually the same, aliases (or potential
>> aliases) are handled correctly.  However, it turns out to be quite
>> difficult to specify all this, and it is a work in progress (both for
>> language standards and implementations).
>
> provenance?

Yes, that's the word I intended to use! Once Thunderbird's auto-correct
had turned my mangled guess at the spelling into a correctly spelt but
unintended word, I reused it without thinking.

Re: Paper about ISO C

<sjpoti$dv$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20772&group=comp.arch#20772

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 15:42:42 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sjpoti$dv$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjoo12$9vc$2@newsreader4.netcologne.de> <sjpb9c$d03$1@dont-email.me>
Injection-Date: Fri, 8 Oct 2021 15:42:42 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:2fa2:0:7285:c2ff:fe6c:992d";
logging-data="447"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 8 Oct 2021 15:42 UTC

David Brown <david.brown@hesbynett.no> schrieb:
> On 08/10/2021 08:21, Thomas Koenig wrote:
>> David Brown <david.brown@hesbynett.no> schrieb:
>>> "We were all
>>> happy and no bugs existed in code until gcc sinned by optimising code,
>>> and we were thrown out of Eden into a hell of undefined behaviour".
>>
>> *snarf*
>>
>> That was the sound of that qoute hitting the gcc bugzilla quip file.
>>
>
> I hope you didn't attribute it as a real quotation from the referenced
> paper!

No, I just added the sentence as is (with Americanized spelling).

I thought it fit the critera of "something clever or funny or
boring (but not obscene or offensive, please)".

(If you have a bugzilla account, you can also extend the quip list;
I have put in a few over the years).

Re: Paper about ISO C

<sjppmp$ra$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20775&group=comp.arch#20775

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!aioe.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 15:56:09 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <sjppmp$ra$1@newsreader4.netcologne.de>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
<sjpec8$b1t$1@z-news.wcss.wroc.pl>
Injection-Date: Fri, 8 Oct 2021 15:56:09 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-2fa2-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:2fa2:0:7285:c2ff:fe6c:992d";
logging-data="874"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 8 Oct 2021 15:56 UTC

antispam@math.uni.wroc.pl <antispam@math.uni.wroc.pl> schrieb:
> MitchAlsup <MitchAlsup@aol.com> wrote:
>> On Thursday, October 7, 2021 at 3:47:23 PM UTC-5, BGB wrote:
>> > Whereas, say:
>> > x=foo->bar->x;
>> > y=foo->bar->y;
>> > Becomes, effectively:
>> > t0=foo->bar;
>> > x=t0->x;
>> > y=t0->y;
>> <
>> In Operating System code; if one write the top 2 statements, one should
>> get at least 4 loads--it is simply UNSAFE to assume otherwise--even
>> if x happens to be allocated into a register (which may happen FAR after
>> aliasing analysis is performed.)
>
> Sorry, code _assuming_ aliasing there is simply insane, regardless
> if this in operating system on not. If anybody really needs
> aliansing in such context this should be done by special purpose
> construct.

Which is why I like Fortran's handling of pointers and allocatables
better than C's.

In Fortran, a pointer is an alias to a variable. That variable
can be allocated via the ALLOCATE statement or can be a variable
declared with the TARGET attribute. The compiler can assume
(and, to a large extent, check) that no pointer points at
something that is not a TARGET. Pointers to arrays, or parts
of arrays, are also possible.

An allocatable variable is a different beast. It is allocated by
an ALLOCATE statement or by automatic (re-)allocation. No other
pointer can point to it, unless it is also declared TARGET.
It is also deallocated automatically upon going out of scope.

And a dummy argument (parameter in C) is something else again.
You cannot have these aliasing when one of them is assigned to.

C has conflated these three concepts into one, pointers, together
with pointer arithmetic for array access. This all made sense
in the 1970s when the language was designed for when the language
had to fit on a small machine. Today, not so much.

Re: Paper about ISO C

<aTZ7J.138342$F26.9781@fx44.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20776&group=comp.arch#20776

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx44.iad.POSTED!not-for-mail
From: ThatWoul...@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <sjnmcp$630$1@dont-email.me> <ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com> <967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com> <jlN7J.12573$fZ.8007@fx06.iad> <c0nvlg9c4v1u2m4t9601rb02u7i6g1b3pg@4ax.com>
In-Reply-To: <c0nvlg9c4v1u2m4t9601rb02u7i6g1b3pg@4ax.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 49
Message-ID: <aTZ7J.138342$F26.9781@fx44.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Fri, 08 Oct 2021 15:56:54 UTC
Date: Fri, 08 Oct 2021 11:56:32 -0400
X-Received-Bytes: 3060
X-Original-Bytes: 3009
 by: EricP - Fri, 8 Oct 2021 15:56 UTC

George Neuner wrote:
> On Fri, 08 Oct 2021 01:41:35 GMT, Branimir Maksimovic
> <branimir.maksimovic@icloud.com> wrote:
>
>> On 2021-10-08, MitchAlsup <MitchAlsup@aol.com> wrote:
>>> On Thursday, October 7, 2021 at 7:46:28 PM UTC-5, MitchAlsup wrote:
>>> <
>>> You see, here is the dilemma::
>>> <
>>> Assume 2 OS threads, the first in service of a trap from thread[t],
>>> The second in service of a trap from thread[h].
>>> <
>>> OS[t] creates a pointer into thread[t]. Can this pointer be used in any
>>> meaningful way in OS[h] ?
>>> <
>>> No (99.99%) of the time. The lower ½ of OS[t] address space is completely
>>> unrelated to the lower ½ of OS[h] address space--even though 100% of the
>>> upper ½ address space is shared between OS[t] and OS[h]!
>>>
>> Isn't it that threads are defined as sharing same address space, unlike
>> processes? Actually there is no other difference between processes and
>> threads...
>
> That's a de facto definition rather than a canon one. Technically
> both "process" and "thread" are execution contexts, and they mean
> whatever they are defined to mean in a given system. The idea that a
> process represents an address space / protection domain while a thread
> represents a code path is really only an artifact of the way in which
> threads initially were implemented.
>
> As a counter example, consider that on the Mill multiple threads in
> the same program simultaneously can be in different protection
> domains.
>
> Take a look at "scheduler activations" for a different idea of how the
> kernel can support multiple threads.
> https://homes.cs.washington.edu/~tom/pubs/sched_act.pdf
> http://web.mit.edu/nathanw/www/usenix/freenix-sa/freenix-sa.html
>
> Note: scheduler activations initially may /look/ similar to M:N
> threading (userspace threads multiplexed on kernel threads), but
> underneath they are quite different.

Unless I missed something, these scheduler activations are user mode
threads that switch on blocking events like page faults to a different
user mode thread by having the OS punt back to user mode on blocking.
Why wouldn't I just use normal kernel scheduled threads?

Re: Paper about ISO C

<sjpqlr$rkt$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20777&group=comp.arch#20777

  copy link   Newsgroups: comp.arch
Path: rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 18:12:42 +0200
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <sjpqlr$rkt$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjoo12$9vc$2@newsreader4.netcologne.de> <sjpb9c$d03$1@dont-email.me>
<sjpoti$dv$1@newsreader4.netcologne.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Oct 2021 16:12:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="747e27c5905b57615cabb4adc19381e0";
logging-data="28317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gu+KsqsIoXd/p4MPnaUZumNTSid76MFs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:REIuNlRl1W9zvtAl3dYXSrkjaFw=
In-Reply-To: <sjpoti$dv$1@newsreader4.netcologne.de>
Content-Language: en-GB
 by: David Brown - Fri, 8 Oct 2021 16:12 UTC

On 08/10/2021 17:42, Thomas Koenig wrote:
> David Brown <david.brown@hesbynett.no> schrieb:
>> On 08/10/2021 08:21, Thomas Koenig wrote:
>>> David Brown <david.brown@hesbynett.no> schrieb:
>>>> "We were all
>>>> happy and no bugs existed in code until gcc sinned by optimising code,
>>>> and we were thrown out of Eden into a hell of undefined behaviour".
>>>
>>> *snarf*
>>>
>>> That was the sound of that qoute hitting the gcc bugzilla quip file.
>>>
>>
>> I hope you didn't attribute it as a real quotation from the referenced
>> paper!
>
> No, I just added the sentence as is (with Americanized spelling).
>
> I thought it fit the critera of "something clever or funny or
> boring (but not obscene or offensive, please)".
>
> (If you have a bugzilla account, you can also extend the quip list;
> I have put in a few over the years).
>

I do have an account, and have registered a few bugs, but I did not know
about the quip list. It's always a rare pleasure to learn something new
from Usenet!

Re: Paper about ISO C

<sjprtg$259$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20779&group=comp.arch#20779

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: iva...@millcomputing.com (Ivan Godard)
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
Date: Fri, 8 Oct 2021 09:33:53 -0700
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <sjprtg$259$1@dont-email.me>
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me>
<sjnmcp$630$1@dont-email.me>
<ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com>
<967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com>
<jlN7J.12573$fZ.8007@fx06.iad> <c0nvlg9c4v1u2m4t9601rb02u7i6g1b3pg@4ax.com>
<aTZ7J.138342$F26.9781@fx44.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 8 Oct 2021 16:33:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d1d272887b4bad0d5b4c01b0d56b7f5e";
logging-data="2217"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BCNc380BQrbg8iDaCZyEL"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:EMp9hML4JlhiG2fFl9fu4O+ljK8=
In-Reply-To: <aTZ7J.138342$F26.9781@fx44.iad>
Content-Language: en-US
 by: Ivan Godard - Fri, 8 Oct 2021 16:33 UTC

On 10/8/2021 8:56 AM, EricP wrote:
> George Neuner wrote:
>> On Fri, 08 Oct 2021 01:41:35 GMT, Branimir Maksimovic
>> <branimir.maksimovic@icloud.com> wrote:
>>
>>> On 2021-10-08, MitchAlsup <MitchAlsup@aol.com> wrote:
>>>> On Thursday, October 7, 2021 at 7:46:28 PM UTC-5, MitchAlsup wrote:
>>>> <
>>>> You see, here is the dilemma::
>>>> <
>>>> Assume 2 OS threads, the first in service of a trap from thread[t],
>>>> The second in service of a trap from thread[h].
>>>> <
>>>> OS[t] creates a pointer into thread[t]. Can this pointer be used in any
>>>> meaningful way in OS[h] ?
>>>> <
>>>> No (99.99%) of the time. The lower ½ of OS[t] address space is
>>>> completely
>>>> unrelated to the lower ½ of OS[h] address space--even though 100% of
>>>> the
>>>> upper ½ address space is shared between OS[t] and OS[h]!
>>>>
>>> Isn't it that threads are defined as sharing same address space, unlike
>>> processes?  Actually there is no other difference between processes and
>>> threads...
>>
>> That's a de facto definition rather than a canon one.  Technically
>> both "process" and "thread" are execution contexts, and they mean
>> whatever they are defined to mean in a given system.  The idea that a
>> process represents an address space / protection domain while a thread
>> represents a code path is really only an artifact of the way in which
>> threads initially were implemented.
>>
>> As a counter example, consider that on the Mill multiple threads in
>> the same program simultaneously can be in different protection
>> domains.
>>
>> Take a look at "scheduler activations" for a different idea of how the
>> kernel can support multiple threads.
>> https://homes.cs.washington.edu/~tom/pubs/sched_act.pdf
>> http://web.mit.edu/nathanw/www/usenix/freenix-sa/freenix-sa.html
>>
>> Note: scheduler activations initially may /look/ similar to M:N
>> threading (userspace threads multiplexed on kernel threads), but
>> underneath they are quite different.
>
> Unless I missed something, these scheduler activations are user mode
> threads that switch on blocking events like page faults to a different
> user mode thread by having the OS punt back to user mode on blocking.
> Why wouldn't I just use normal kernel scheduled threads?
>
>

Because, for most current systems, a kernel thread switch is thousands
of cycles.

Re: Paper about ISO C

<E0%7J.9319$7U3.7165@fx24.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=20781&group=comp.arch#20781

  copy link   Newsgroups: comp.arch
Path: rocksolid2!i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx24.iad.POSTED!not-for-mail
From: ThatWoul...@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Paper about ISO C
References: <87fstdumxd.fsf@hotmail.com> <sjni60$97d$1@dont-email.me> <sjnmcp$630$1@dont-email.me> <ca22ba8c-2f32-4999-a2d0-edde18d97a24n@googlegroups.com> <967daf46-d627-4db5-9e5f-0584ac00a539n@googlegroups.com> <jlN7J.12573$fZ.8007@fx06.iad> <c0nvlg9c4v1u2m4t9601rb02u7i6g1b3pg@4ax.com> <aTZ7J.138342$F26.9781@fx44.iad> <sjprtg$259$1@dont-email.me>
In-Reply-To: <sjprtg$259$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 72
Message-ID: <E0%7J.9319$7U3.7165@fx24.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Fri, 08 Oct 2021 17:15:16 UTC
Date: Fri, 08 Oct 2021 13:14:37 -0400
X-Received-Bytes: 4150
 by: EricP - Fri, 8 Oct 2021 17:14 UTC

Ivan Godard wrote:
> On 10/8/2021 8:56 AM, EricP wrote:
>> George Neuner wrote:
>>> On Fri, 08 Oct 2021 01:41:35 GMT, Branimir Maksimovic
>>> <branimir.maksimovic@icloud.com> wrote:
>>>
>>>> On 2021-10-08, MitchAlsup <MitchAlsup@aol.com> wrote:
>>>>> On Thursday, October 7, 2021 at 7:46:28 PM UTC-5, MitchAlsup wrote:
>>>>> <
>>>>> You see, here is the dilemma::
>>>>> <
>>>>> Assume 2 OS threads, the first in service of a trap from thread[t],
>>>>> The second in service of a trap from thread[h].
>>>>> <
>>>>> OS[t] creates a pointer into thread[t]. Can this pointer be used in
>>>>> any
>>>>> meaningful way in OS[h] ?
>>>>> <
>>>>> No (99.99%) of the time. The lower ½ of OS[t] address space is
>>>>> completely
>>>>> unrelated to the lower ½ of OS[h] address space--even though 100%
>>>>> of the
>>>>> upper ½ address space is shared between OS[t] and OS[h]!
>>>>>
>>>> Isn't it that threads are defined as sharing same address space, unlike
>>>> processes? Actually there is no other difference between processes and
>>>> threads...
>>>
>>> That's a de facto definition rather than a canon one. Technically
>>> both "process" and "thread" are execution contexts, and they mean
>>> whatever they are defined to mean in a given system. The idea that a
>>> process represents an address space / protection domain while a thread
>>> represents a code path is really only an artifact of the way in which
>>> threads initially were implemented.
>>>
>>> As a counter example, consider that on the Mill multiple threads in
>>> the same program simultaneously can be in different protection
>>> domains.
>>>
>>> Take a look at "scheduler activations" for a different idea of how the
>>> kernel can support multiple threads.
>>> https://homes.cs.washington.edu/~tom/pubs/sched_act.pdf
>>> http://web.mit.edu/nathanw/www/usenix/freenix-sa/freenix-sa.html
>>>
>>> Note: scheduler activations initially may /look/ similar to M:N
>>> threading (userspace threads multiplexed on kernel threads), but
>>> underneath they are quite different.
>>
>> Unless I missed something, these scheduler activations are user mode
>> threads that switch on blocking events like page faults to a different
>> user mode thread by having the OS punt back to user mode on blocking.
>> Why wouldn't I just use normal kernel scheduled threads?
>>
>>
>
> Because, for most current systems, a kernel thread switch is thousands
> of cycles.

According to the HTML paper dated 2002 titled
"An Implementation of Scheduler Activations on the NetBSD Operating System"
in the section "Performance Analysis"
a Linux 2.4.19 kernel thread context switch is 82 us,
GNU PTH Portable Threads user mode library on NetBSD is 166 us,
and Scheduler Activations on NetBSD is 225 us.

I don't know what that 2002 version of Linux scheduler did but
around that time they used a single Big Lock for many OS resources.
Since then much of the locking has been made finer grain and scheduling
in particular is separated for each core so no locking is required.
So kernel thread context switch should be proportionally even faster.

Pages:123456789101112131415161718192021222324252627282930313233
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor