The HTML files now include a comment indicating from where the main part of the markdown content. Changed `bin/gen-other-html.sh` VERSION from "1.0 2024-02-27" to "1.0.1 2024-03-08". Changed `bin/gen-top-html.sh` VERSION from "1.2 2024-02-29" to "1.2.1 2024-03-08". Changed `bin/gen-year-index.sh` VERSION from "1.0.1 2024-02-23" to "1.0.2 2024-03-08". Changed `bin/md2html.sh` VERSION from "1.0.1 2024-02-23" to "1.1 2024-03-08". Changed `bin/quick-readme2index.sh` VERSION from "1.1.1 2024-02-23" to "1.1.2 2024-03-08".
331 lines
18 KiB
HTML
331 lines
18 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||
<!-- START: two lines up starts content from: inc/top.default.html -->
|
||
<!-- -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- -->
|
||
<!-- END: this line ends content from: inc/top.default.html -->
|
||
<!-- -->
|
||
<!-- The original markdown content was formed by the tool: bin/readme2index.sh -->
|
||
<!-- The main part of the markdown content came from: 1996/schweikh3/README.md -->
|
||
<!-- The HTML was converted from markdown by the tool: bin/md2html.sh -->
|
||
<!-- -->
|
||
<!-- START: this line starts content from: inc/head.default.html -->
|
||
|
||
<head>
|
||
<link rel="stylesheet" href="../../ioccc.css">
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||
<title>1996/schweikh3 - Best Utility</title>
|
||
<meta name="description" content="1996 IOCCC entry schweikh3 - Best Utility">
|
||
<meta name="keywords" content="IOCCC, 1996, IOCCC 1996, IOCCC entry, schweikh3, Best Utility">
|
||
</head>
|
||
|
||
<!-- END: this line ends content from: inc/head.default.html -->
|
||
<!-- START: this line starts content from: inc/body.default.html -->
|
||
|
||
<body>
|
||
|
||
<!-- END: this line ends content from: inc/body.default.html -->
|
||
<!-- START: this line starts content from: inc/header.default.html -->
|
||
|
||
<div class="header">
|
||
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
|
||
<h1>The International Obfuscated C Code Contest</h1>
|
||
<h2>1996/schweikh3 - Best Utility</h2>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/topnav.mid.html -->
|
||
|
||
<div class="topnav">
|
||
<a class="Left" href="../schweikh2/index.html">← schweikh2</a>
|
||
<a class="Left" href="../index.html">↑ 1996 ↑</a>
|
||
<a class="Left" href="../westley/index.html">westley →</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/1996/schweikh3/schweikh3.c">C code</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/1996/schweikh3/Makefile">Makefile</a>
|
||
<a class="Right" href="#inventory">Inventory</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/topnav.mid.html -->
|
||
<!-- START: this line starts content from: inc/begin-row.default.html -->
|
||
|
||
<div class="row">
|
||
|
||
<!-- END: this line ends content from: inc/begin-row.default.html -->
|
||
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
|
||
|
||
<div class="leftcolumn">
|
||
|
||
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/sidenav.default.html -->
|
||
|
||
<div class="sidenav">
|
||
<a href="#content">Jump to contents</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../index.html">IOCCC Home</a>
|
||
<a href="../../years.html">Winning Entries</a>
|
||
<a href="../../authors.html">People who have won</a>
|
||
<a href="../../location.html">Location of authors</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../news.html">IOCCC News</a>
|
||
<a href="../../faq.html#submit">How to enter the IOCCC</a>
|
||
<a href="../../faq.html">FAQ</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../bugs.html">Bugs & (mis)features</a>
|
||
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
|
||
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
|
||
<a href="../../faq.html#fix_author">Fixing author info</a>
|
||
<a href="../../thanks-for-help.html">Thanks for the help</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="../../judges.html">The IOCCC Judges</a>
|
||
<a href="../../contact.html">Contacting the IOCCC</a>
|
||
</div>
|
||
<hr>
|
||
<div class="sidenav">
|
||
<a href="#top">Jump to top</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/sidenav.default.html -->
|
||
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
|
||
|
||
<div class="rightcolumn">
|
||
|
||
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||
|
||
<a name="content"></a>
|
||
|
||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
|
||
|
||
<h2 id="author"><a name="author"></a>Author:</h2>
|
||
<ul>
|
||
<li>Name: <a href="../../authors.html#Jens_Schweikhardt">Jens
|
||
Schweikhardt</a><br> Location: <a href="../../location.html#DE">DE</a> -
|
||
<em>Federal Republic of Germany</em> (<em>Germany</em>) <br><br></li>
|
||
</ul>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
|
||
<h2 id="to-build">To build:</h2>
|
||
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> all</span></code></pre></div>
|
||
<h2 id="to-use">To use:</h2>
|
||
<p><strong>WARNING: DO NOT RUN this program without reading this text
|
||
down to the end!</strong> It may render your system unusable for a
|
||
limited amount of time or force you to reboot using the Big Red Button!
|
||
This is <strong>NOT</strong> a joke. You have been warned.</p>
|
||
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./schweikh3</span></span></code></pre></div>
|
||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||
<p>The source fails to compile on compilers that recognize the inline
|
||
keyword by default. For gcc, you may need to use <code>-ansi</code>.</p>
|
||
<p>See the file <a href="schweikh3.info">schweikh3.info</a> for example
|
||
output from various systems.</p>
|
||
<p>But still it is a useful utility. To use try:</p>
|
||
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">./schweikh3</span></span></code></pre></div>
|
||
<p>and thanks for the virtual memories! :-)</p>
|
||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||
<h3 id="why-i-think-my-entry-is-obfuscated">Why I think my entry is
|
||
obfuscated</h3>
|
||
<p>There are some layout obfuscations that hinder readability, like some
|
||
(but not all) one character tokens in column 1. <code>#include</code>s,
|
||
<code>#define</code>s and declarations of data and functions appear
|
||
intermixed. <code>iso646.h</code> is even included in the middle of an
|
||
expression, how disgusting. Besides, requiring <code>iso646.h</code>
|
||
will render the program uncompilable on many systems that have not yet
|
||
incorporated Amendment One to The Standard. If you, dear reader, suffer
|
||
from this disease, just read <code>iso646.h</code>.</p>
|
||
<p>There are no
|
||
<code>if' statements. They have been replaced by</code>switch () case
|
||
1:<code>or</code>switch () case
|
||
0:<code>etc. At least one</code>switch<code>has a declaration after the opening brace, booh! Identifiers are named after random programming languages, BASIC (as</code>Basic`),
|
||
COBOL, F77, awk etc.</p>
|
||
<p>You have to select maximum ANSI C conformance of your compiler. The
|
||
source fails to compile under a C++ compiler due to the `new’ identifier
|
||
which is a C++ reserved word:</p>
|
||
<div class="sourceCode" id="cb4"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> g++ schweikh3.c</span>
|
||
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="ex">schweikh3.c:9:</span> parse error before <span class="kw">`</span><span class="ex">new</span><span class="st">'</span></span>
|
||
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="st">schweikh3.c:16: parse error before `new'</span></span>
|
||
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="ex">schweikh3.c:46:</span> parse error before <span class="kw">`</span>void<span class="st">'</span></span>
|
||
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="st">schweikh3.c:65: parse error before `Lisp'</span></span>
|
||
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="ex">schweikh3.c:68:</span> parse error before <span class="kw">`;</span><span class="st">'</span></span>
|
||
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="st">[...]</span></span>
|
||
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a><span class="st">schweikh3.c:91: confused by earlier errors, bailing out</span></span></code></pre></div>
|
||
<p>The source fails to compile on compilers that recognize the inline
|
||
keyword by default, e.g. gcc:</p>
|
||
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> gcc schweikh3.c</span>
|
||
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="ex">schweikh3.c:46:</span> parse error before <span class="kw">`</span><span class="ex">void</span><span class="st">'</span></span>
|
||
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="st">schweikh3.c: In function `main'</span><span class="ex">:</span></span>
|
||
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="ex">schweikh3.c:91:</span> parse error before <span class="kw">`</span>inline<span class="st">'</span></span>
|
||
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="st">schweikh3.c: At top level:</span></span>
|
||
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="st">schweikh3.c:97: parse error before `void'</span></span></code></pre></div>
|
||
<p>The <code>-ansi</code> option to gcc fixes this.</p>
|
||
<p>The source fails to compile on obsolete systems with obsolete memory
|
||
models due to the identifier <code>far</code> (to be honest: this is
|
||
untested :-) ).</p>
|
||
<p>Does your indent cope with backslash/newline pairs in between
|
||
keywords like in <code>re\turn</code> where the <code>re\</code> is at
|
||
the end of a line? ? Solaris’ indent inserts spaces and thereby renders
|
||
the source uncompilable…</p>
|
||
<p>The indented source will exhibit different semantics when indenting
|
||
changes the number of lines (due to using the <code>__LINE__</code>
|
||
macro in an expression).</p>
|
||
<p>And what about <code>sizeof __TIME__</code>? This one’s for the
|
||
philosophers and physicists among us programmers. What is it?
|
||
<code>sizeof (char *)</code>? – no. <code>strlen ("hh:mm:ss")</code>? –
|
||
no. It’s the same as <code>sizeof __DATE__ - sizeof "no"</code> :-)</p>
|
||
<p>The program is POSIX conformant and lints without warning under
|
||
Solaris’ Sunpro lint. Allocated memory is correctly freed on all
|
||
possible execution paths.</p>
|
||
<h3 id="what-this-program-does">What this program does</h3>
|
||
<p>This program tests your operating system’s allocation honesty. It
|
||
forks a child that will allocate as much memory as possible with byte
|
||
granularity and then write to every 1024th byte, at the same time
|
||
writing a status report on <code>stdout</code>. This way each page of
|
||
the allocated virtual memory will eventually be referenced. Without any
|
||
arguments, <code>malloc(3)</code> will be used to allocate memory. If
|
||
the first arg starts with <code>c</code>, <code>calloc(3)</code> will be
|
||
used instead.</p>
|
||
<p>I distinguish three different behaviours:</p>
|
||
<ol type="1">
|
||
<li><p>OS without memory overcommit: <code>malloc(3)</code> does not lie
|
||
– you can use all memory the OS granted to you.</p></li>
|
||
<li><p>OS with memory overcommit: <code>malloc(3)</code> lies – any
|
||
program may get killed at random when the OS can not acquire a free
|
||
page.</p></li>
|
||
<li><p>OS with pseudo memory overcommit: <code>malloc(3)</code> lies –
|
||
The OS puts processes to sleep for which it can not acquire a free page.
|
||
Because other processes are also affected this way, the system slows
|
||
down and quickly becomes totally unusable (also known as “thrashing”).
|
||
Because more and more processes wait for memory returned by other
|
||
exiting processes the system eventually enters a deadlock situation and
|
||
effectively halts.</p></li>
|
||
</ol>
|
||
<p>I had the pleasure and pain to find all three behaviours on the
|
||
platforms I use regularly.</p>
|
||
<p>The file <a href="schweikh3.info">schweikh3.info</a> has output for
|
||
Solaris, FreeBSD and Linux. The Linux case is interesting in that the
|
||
behaviour changes when <code>calloc(3)</code> is used instead of
|
||
<code>malloc(3)</code>. For FreeBSD, the last two lines are not messages
|
||
stemming from my program but issued by the syslog daemon.</p>
|
||
<h3 id="implementation-remarks">Implementation remarks</h3>
|
||
<p>How can we distinguish the three different OS types from the table
|
||
above?</p>
|
||
<p>Obviously, type (1), no overcommit, is easy.</p>
|
||
<p>For type (2), random kill, we need to fork a child that can be killed
|
||
and whose exit status the parent collects and decodes. Here’s where
|
||
POSIX enters the scene.</p>
|
||
<p>Type (3), thrashing, was the hardest part. The first attempt was to
|
||
measure the elapsed processor time it takes to write a single byte
|
||
(using <code>clock()</code>). If a certain threshold is reached I assume
|
||
the system is thrashing. When thrashing, however, the process does not
|
||
consume processor time in a noticeable amount any longer and I lose. So
|
||
I switched to measuring wall clock time using <code>time(3)</code>. On
|
||
the one system that I observe thrashing (Linux) this works (although the
|
||
value returned by <code>time(3)</code> seems to ‘hang’ sometimes when
|
||
the OS thrashes. Exceeding a threshold of 5 seconds may be detected only
|
||
after half a minute or so.</p>
|
||
<h2 id="copyright-and-cc-by-sa-4.0-license">Copyright and CC BY-SA 4.0
|
||
License:</h2>
|
||
<p>This file is Copyright (c) 2023 by Landon Curt Noll. All Rights
|
||
Reserved. You are free to share and adapt this file under the terms of
|
||
this license:</p>
|
||
<pre><code>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)</code></pre>
|
||
<p>For more information, see:
|
||
https://creativecommons.org/licenses/by-sa/4.0/</p>
|
||
|
||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<h1 id="inventory-for-1996schweikh3"><a name="inventory"></a>Inventory
|
||
for 1996/schweikh3</h1>
|
||
<p><a href="#top">Jump to top</a></p>
|
||
<h2 id="primary-files">Primary files</h2>
|
||
<ul>
|
||
<li><a
|
||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1996/schweikh3/schweikh3.c">schweikh3.c</a>
|
||
- entry source</li>
|
||
<li><a
|
||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1996/schweikh3/Makefile">Makefile</a>
|
||
- entry Makefile</li>
|
||
<li><a
|
||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1996/schweikh3/schweikh3.orig.c">schweikh3.orig.c</a>
|
||
- original source</li>
|
||
<li><a
|
||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1996/schweikh3/schweikh3.info">schweikh3.info</a>
|
||
- example output from various systems</li>
|
||
<li><a href="1996_schweikh3.tar.bz2">1996_schweikh3.tar.bz2</a> -
|
||
download entry source</li>
|
||
</ul>
|
||
<h2 id="secondary-files">Secondary files</h2>
|
||
<ul>
|
||
<li><a href="index.html">index.html</a> - entry home page</li>
|
||
<li><a
|
||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1996/schweikh3/.entry.json">.entry.json</a>
|
||
- description of entry in JSON</li>
|
||
<li><a
|
||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1996/schweikh3/.gitignore">.gitignore</a>
|
||
- list of files that should not be committed under git</li>
|
||
<li><a href=".path">.path</a> - directory path from top directory</li>
|
||
<li><a
|
||
href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1996/schweikh3/README.md">README.md</a>
|
||
- markdown source for index.html</li>
|
||
</ul>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content from: inc/after-content.default.html -->
|
||
|
||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
|
||
<!-- START: this line starts content from: inc/end-row.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/end-row.default.html -->
|
||
<!-- START: this line starts content from: inc/footer.default.html -->
|
||
|
||
<div class="footer">
|
||
<hr>
|
||
<h2>Coda</h2>
|
||
<p><a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F1996%2Fschweikh3%2Findex.html">Nu HTML check this web page</a></p>
|
||
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.default.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|