<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://www.baszerr.eu/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>BaSzErr - blog:2016:07:10</title>
        <description></description>
        <link>https://www.baszerr.eu/</link>
        <lastBuildDate>Wed, 06 May 2026 09:35:15 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://www.baszerr.eu/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>BaSzErr</title>
            <link>https://www.baszerr.eu/</link>
        </image>
        <item>
            <title>boot-id</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2016:07:10:boot-id</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;boot-id&quot;&gt;2016-07-10 - boot-ID&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
some time ago, in a project not so far away, we had a problem. :) a connection-less channel had to be used for polling between two services, to detect failures/reboots on remote ends. it was meant not to use “too much bandwidth”, so connection was checked every 15[s], or so. there was one “surprise” awaiting though – what will happen if remote end will manage to restart in between two checks? crash will not be detected and application states will get out of sync! the answer was simple – add a &lt;em&gt;boot-ID&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;boot-ID&lt;/em&gt; is a simple, &lt;a href=&quot;https://en.wikipedia.org/wiki/PRNG&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/PRNG&quot;&gt;pseudo-random&lt;/a&gt; string, that is re-generated by an application upon each start and is never stored persistently. this way, each time application starts, it gets new &lt;em&gt;boot-ID&lt;/em&gt;. adding this mechanism to heartbeats/ping-pong messages, polling can be arbitrary long and still detect a failure, since each time reboot/reset occurs, new &lt;em&gt;boot-ID&lt;/em&gt; is assigned thus remote application knows “logical connection” was lost.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/UUID&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/UUID&quot;&gt;UUID&lt;/a&gt; is an example of possible &lt;em&gt;boot-ID&lt;/em&gt;, but in fact any string will do, as long as it is not probable to get the same ID twice in a row. mechanism is trivial to implement and bullet-proof in real-life.
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:20 +0000</pubDate>
        </item>
        <item>
            <title>constexpr_and_floating-point</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2016:07:10:constexpr_and_floating-point</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;constexpr_and_floating-point&quot;&gt;2016-07-10 - constexpr and floating-point&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
in &lt;a href=&quot;https://en.wikipedia.org/wiki/C++&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/C++&quot;&gt;C++&lt;/a&gt; a &lt;a href=&quot;https://en.wikipedia.org/wiki/constexpr&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/constexpr&quot;&gt;constexpr&lt;/a&gt; keyword can be applied to a function. such a function can either be evaluated at run-time or (if possible) at compile-time. now let&amp;#039;s have a look at the following trivial example:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;
using namespace std&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
constexpr &lt;span class=&quot;kw4&quot;&gt;double&lt;/span&gt; foo&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;double&lt;/span&gt; a&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;double&lt;/span&gt; b&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; a &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; b&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span class=&quot;kw4&quot;&gt;double&lt;/span&gt; a&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;b&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  cin &lt;span class=&quot;sy0&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; a&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  cin &lt;span class=&quot;sy0&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; b&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// 1) compile-time:&lt;/span&gt;
  cout &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; foo&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu16&quot;&gt;1.333&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu16&quot;&gt;2.666&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; endl&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;co1&quot;&gt;// 2) run-time:&lt;/span&gt;
  cout &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; foo&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;a&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; b&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; endl&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
assuming used will provide &lt;em&gt;a = 1.333&lt;/em&gt; and &lt;em&gt;b = 2.666&lt;/em&gt;, it is pretty obvious, that both cases should print the same result. now an interesting question part – what will happen in case of cross-compilation, where target architecture has a different floating-point precision, than the host, performing a cross-compilation? this question arose during a post-seminar discussion, on one of the conferences. since i do a lot of embedded programing it turned out to be quite an interesting.
&lt;/p&gt;

&lt;p&gt;
at first one could think results may differ, since it would be natural for an implementation to use &lt;em&gt;double&lt;/em&gt; type and operations, offered by a local hardware.
&lt;/p&gt;

&lt;p&gt;
fortunately C++14 makes, section 7.1.5/7 makes it clear:
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;A call to a constexpr function produces the same result as a call to an equivalent non-constexpr function in all respects except that a call to a constexpr function can appear in a constant expression.&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
so developers are on a safe side – results will always be the same. however compilers&amp;#039; developers have one more extra thing to do, when implementing cross-compilation, in a context of constexpr functions – they need to emulate floating-point of a target hardware, if it differs from host&amp;#039;s.
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:20 +0000</pubDate>
        </item>
        <item>
            <title>elevators</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2016:07:10:elevators</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;elevators&quot;&gt;2016-07-10 - elevators&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.baszerr.eu/lib/exe/detail.php?id=blog%3A2016%3A07%3A10%3Aelevators&amp;amp;media=blog:2016:07:10:elevator.jpg&quot; class=&quot;media&quot; title=&quot;blog:2016:07:10:elevator.jpg&quot;&gt;&lt;img src=&quot;https://www.baszerr.eu/lib/exe/fetch.php?w=300&amp;amp;tok=29cc74&amp;amp;media=blog:2016:07:10:elevator.jpg&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;elevator symbol (taken from wikipedia)&quot; alt=&quot;elevator symbol (taken from wikipedia)&quot; width=&quot;300&quot; /&gt;&lt;/a&gt;
in high buildings there is a problem with time it takes to travel by elevators. elevator speed is one thing, but stopping on every floor is even worse, since there is no time to accelerate and doors need to remain open for a long periods of time on each floor.
&lt;/p&gt;

&lt;p&gt;
it is usually mitigated by adding more elevator shafts. recently i though about doing this in a bit different manner. how about adding more shafts, but each elevator would stop every N-th floor. for instance having 30 floors and 3 shafts (i.e. N=3):
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; elevator 1 would stop on floors 1, 4, 7, etc… &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; elevator 2 would stop on floors 2, 5, 8, etc…&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; elevator 3 would stop on floors 3, 6, 9, etc…&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
this way each set of floors would have dedicated elevator, this from each elevators&amp;#039; PoV it would be as if building had just 10 (in general: one N-th) floors. travel speeds could be much higher, w/o loosing a comfort of smooth speed ups and breaking. also, on average less ppl would travel by each elevator, thus reducing power needed to move around.
&lt;/p&gt;

&lt;p&gt;
of course, since most ppl do need to access ground floor, it would have to be common for all elevators (as an exception).
&lt;/p&gt;

&lt;p&gt;
how to operate that? it&amp;#039;s simple – just press the button (outside of the elevator!), saying where you want to go, and you&amp;#039;ll be given shaft number to await at. then just wait for a proper elevator to arrive. when your elevator arrives, you just enter it and travel. as a free bonus - since the elevator already knows where you&amp;#039;re heading (you&amp;#039;ve selected the floor when requesting an elevator), there is no need to squeeze through group of ppl, just to press the button. in fact – the only button such elevator needs to have inside are an emergency stop and a call for service. :)
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:20 +0000</pubDate>
        </item>
        <item>
            <title>how_about_it_crowd_pub</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2016:07:10:how_about_it_crowd_pub</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;how_about_it_crowd_pub&quot;&gt;2016-07-10 - how about IT crowd pub?&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
it is amazing how technologically advanced topics can play a key role over a beer with other tech-geeks. :) recently i was thinking it would be nice to have a pub with a whiteboards to draw on. or even better – a semi-transparent glass, surrounding each table-sets, where you could discuss ideas and share knowledge with friends, while having a beer at the same time. it would be a sort of hacker-space like thing, just w/o all the hardware to distract you. just pure ideas and a very open discussion. :)
&lt;/p&gt;

&lt;p&gt;
while i&amp;#039;m not planning to open a pub, it would be nice to see some1 bringing this idea into a reality.
&lt;/p&gt;

&lt;p&gt;
if such a place exists already, and you happen to know where, please let me know. :)
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:20 +0000</pubDate>
        </item>
    </channel>
</rss>
