<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>Jehanne</title>
  <link href="/"/>
  <link type="application/atom+xml" rel="self" href="/atom.xml"/>
  <updated>2019-01-06T17:21:24+00:00</updated>
  <id>https://jehanne.io/</id>
  <author>
    <name>Giacomo Tesio</name>
  </author>

  
  
  

  <entry>
    <id>https://jehanne.io/2019/01/06/thought-in-progress</id>

    <link type="text/html" rel="alternate" href="/2019/01/06/thought-in-progress.html"/>

    <title>Thought in progress</title>
    <updated>2019-01-06T00:00:00+00:00</updated>
    <author>
        <name>Giacomo Tesio</name>
        
    </author>
    <content type="html">&lt;p&gt;2018 has gone and from my point of view, it has been a great year.&lt;/p&gt;

&lt;p&gt;I’ve learned the hard way a lot of valuable lessons that broke some
fundamental assumptions of mine, freeing me from several misconceptions and
giving me a priviledged point of view upon important matters.&lt;/p&gt;

&lt;p&gt;First I discovered, with much surprise after years of cynism, that
Free Software and Open Source software are &lt;strong&gt;completely different things&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Everything started when I accidentally discovered that 
&lt;a href=&quot;https://medium.com/@giacomo_59737/what-i-wish-i-knew-before-contributing-to-open-source-dd63acd20696&quot;&gt;Harvey had completely removed my name from their codebase without removing my contributions&lt;/a&gt;.&lt;br /&gt;
This was a blatant violation of the
&lt;a href=&quot;http://www.gnu.org/licenses/gpl-2.0.html&quot;&gt;GNU GPL (version 2)&lt;/a&gt;
from &lt;a href=&quot;https://sfconservancy.org/&quot;&gt;a member of Software Freedom Conservancy&lt;/a&gt;.&lt;br /&gt;
And the commits that removed my name were all from a very experienced Google engineer.&lt;/p&gt;

&lt;p&gt;Since I can’t sue both Google and SFC (they do no Evil, after all!), I had
to surrender when they &lt;a href=&quot;https://github.com/Harvey-OS/harvey/issues/698#issuecomment-365110085&quot;&gt;squashed some of my changes&lt;/a&gt; 
into large commits (that included work from several authors) during a
huge &lt;code class=&quot;highlighter-rouge&quot;&gt;git rebase&lt;/code&gt; that pretended to remove my work (but have left several
of my contributions there).&lt;/p&gt;

&lt;p&gt;The problem is very practical to me, since I reused my changes to the Harvey
codebase in Jehanne, and I’m afraid that a Google’s lawyer could one day decide
that I copied Harvey because of the changes I authored myself.&lt;/p&gt;

&lt;p&gt;All this was a valuable &lt;strong&gt;revelation&lt;/strong&gt;. It taught me that:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;we can’t trust Google’s employees when they contribute to OSS.&lt;/li&gt;
  &lt;li&gt;we can’t trust SFC either, as &lt;a href=&quot;http://punkrocklawyer.com/&quot;&gt;Karen Sandler&lt;/a&gt;
explicitly excluded such kind of issues when Harvey joined SFC.&lt;/li&gt;
  &lt;li&gt;we can’t trust GNU licenses, as it’s violated by SFC members without any issue.&lt;/li&gt;
  &lt;li&gt;talking about FOSS or FLOSS ultimately marginalize hackers.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;beyond-jehanne&quot;&gt;Beyond Jehanne&lt;/h1&gt;

&lt;p&gt;Reflecting on Google, I realized that&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;their lobbying against AI regulation (or for permissive regulations, 
which is the same) is one of the most dangerous attack to worldwide
freedom right now&lt;/li&gt;
  &lt;li&gt;they own Mozilla that don’t give a shit about people privacy or security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In fact the &lt;a href=&quot;https://bugzilla.mozilla.org/show_bug.cgi?id=1487081#c16&quot;&gt;Russian Government&lt;/a&gt;
is exploiting &lt;a href=&quot;https://dev.to/shamar/the-meltdown-of-the-web-4p1m&quot;&gt;one of the attacks&lt;/a&gt;
that I described to &lt;a href=&quot;https://bugzilla.mozilla.org/show_bug.cgi?id=1487081&quot;&gt;Mozilla&lt;/a&gt;
and &lt;a href=&quot;https://bugs.chromium.org/p/chromium/issues/detail?id=879381&quot;&gt;Chromium&lt;/a&gt;
but the bug report is still “RESOLVED INVALID” because
“&lt;a href=&quot;https://bugzilla.mozilla.org/show_bug.cgi?id=1487081#c10&quot;&gt;this is the Web functioning as designed&lt;/a&gt;”&lt;/p&gt;

&lt;p&gt;I mean: the Russian Governement building a database of security researcher
and privacy aware people that could detect a JavaScript attack… is how
Google (and thus Mozilla) want the Web to work.&lt;/p&gt;

&lt;p&gt;The worse vulnerability here is people’s trust in IT.&lt;br /&gt;
Current IT is broken beyond repair.&lt;/p&gt;

&lt;h2 id=&quot;the-only-mitigation-is-culture&quot;&gt;The only mitigation is Culture&lt;/h2&gt;

&lt;p&gt;In 2018 I’ve spent a lot of my free time informing people about the risks of
these attacks. As a consequence, I was banned by a couple of online communities,
&lt;a href=&quot;https://dev.to/shamar/i-have-been-banned-from-lobsters-ask-me-anything-5041&quot;&gt;Lobste.rs&lt;/a&gt; and
&lt;a href=&quot;http://www.tesio.it/cache/2018/TildesNET_Undetectable-Remote-Arbitrary-Code-Execution-Attacks-through-JavaScript-and-HTTP-headers-trickery.html&quot;&gt;Tildes.net&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Much better feedbacks came from &lt;a href=&quot;http://www.tesio.it/talks/&quot;&gt;my talks about AI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But ultimately, I realized that our only hope are kids and I started an
course of Informatics for the elementary school of my eldest daughter.&lt;/p&gt;

&lt;p&gt;I suggest you do to the same: don’t let your children to be used through software.&lt;br /&gt;
We need a generation of &lt;strong&gt;hackers&lt;/strong&gt; that can break the world that bad people have built.&lt;/p&gt;

&lt;h1 id=&quot;yes-but-what-about-jehanne&quot;&gt;Yes but… what about Jehanne?&lt;/h1&gt;

&lt;p&gt;All these facts made me realize that existing copylefts cannot serve neither
hackers’ curiosity nor people’s Freedom, so I studied Copyright regulations to mitigate
the issues I saw with them. The result is the &lt;a href=&quot;http://www.tesio.it/documents/HACK.txt&quot;&gt;Hacking License&lt;/a&gt;
that is going to replace AGPLv3 as my copyleft of choice.&lt;/p&gt;

&lt;p&gt;Writing the Hacking License took roughly 6 months.&lt;br /&gt;
It’s designed to protect users from SaaS’s abuses by granting them the
ultimate right to self-host the application they use. This right will be
a great incentive to fair playing for SaaS providers using my File Protocol.
Also, the Hacking License is designed to turn users to hackers: IMO, this is
the only way Free Software can win against big corporations.&lt;/p&gt;

&lt;p&gt;This is very practical and very important.&lt;br /&gt;
The Web is a half done, badly broken and insecure distributed operating system.&lt;br /&gt;
Using services as a software substitute will be the normal working mode with
Jehanne: if people cannot trust the provider as they cannot trust Web site now
there’s no way to make my project a reality.&lt;/p&gt;

&lt;h2 id=&quot;the-file-protocol&quot;&gt;The File Protocol&lt;/h2&gt;

&lt;p&gt;My few remaining free hours were spent into the design of the File
Protocol (aka FP) and the study of its integration in Jehanne as a
replacement of 9P2000.&lt;/p&gt;

&lt;p&gt;At a first glance all you need to change to introduce an alternative file
protocol in a Plan 9 kernel is devmnt (in Jehanne it was already renamed as
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/93111d7b0ea5b2b1582af1a576ccace7e1fcb9a3/sys/src/kern/port/dev9p.c&quot;&gt;dev9p&lt;/a&gt;)
but after a deeper analysis, it turns out that I have to modify the 
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/93111d7b0ea5b2b1582af1a576ccace7e1fcb9a3/sys/src/kern/port/portdat.h#L197&quot;&gt;Dev structure&lt;/a&gt;
because FP doesn’t have a &lt;a href=&quot;http://man.cat-v.org/9front/5/walk&quot;&gt;Walk&lt;/a&gt; equivalent.&lt;/p&gt;

&lt;p&gt;Changing &lt;code class=&quot;highlighter-rouge&quot;&gt;Dev&lt;/code&gt; has a huge impact on the whole kernel, and it’s just a part
of the issue because I also want to move to a &lt;a href=&quot;http://lsub.org/export/9pix.pdf&quot;&gt;new mount table&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So ultimately, the Jehanne kernel is badly broken right now.&lt;/p&gt;

&lt;p&gt;As a consequence you didn’t saw much work ongoing on Jehanne, and to be honest… 
I wouldn’t hold my breath.&lt;/p&gt;

&lt;p&gt;The File Protocol is the reason Jehanne exists: I want to build the
infrastructure that will let people &lt;strong&gt;hack&lt;/strong&gt; a &lt;strong&gt;free&lt;/strong&gt; and &lt;strong&gt;safe&lt;/strong&gt;
distributed system, so I have to carefully address both the technical and
the legal issues to ensure it won’t end in a user-hostile hell like HTTP
and browsers.&lt;/p&gt;

&lt;p&gt;Because Jehanne is Free Software, &lt;strong&gt;not&lt;/strong&gt; Open Source.&lt;/p&gt;
</content>
  </entry>
    
  
  
  

  <entry>
    <id>https://jehanne.io/2018/11/15/simplicity-awakes</id>

    <link type="text/html" rel="alternate" href="/2018/11/15/simplicity-awakes.html"/>

    <title>Simplicity awakes</title>
    <updated>2018-11-15T00:00:00+00:00</updated>
    <author>
        <name>Giacomo Tesio</name>
        
    </author>
    <content type="html">&lt;p&gt;Preemptive multitasking is now more than 50 years old, initially
introduced in PDP-6 Monitor and MULTICS in 1964. Instead of relying on
processes to cooperatively release the CPU to the kernel, they
registered &lt;a href=&quot;https://en.wikipedia.org/wiki/Interrupt&quot;&gt;timer interrupt handlers&lt;/a&gt;
to move control back to kernel code.&lt;/p&gt;

&lt;p&gt;Nevertheless, processes were still able to yield control of the CPU to
the kernel during a &lt;a href=&quot;https://en.wikipedia.org/wiki/Preemption_(computing)#Time_slice&quot;&gt;time-slice&lt;/a&gt;
by calling any &lt;a href=&quot;https://en.wikipedia.org/wiki/System_call&quot;&gt;system call&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;System calls are often distinguished into blocking or non-blocking
depending on the probability that the kernel will return the control
to the calling process’ code before the next tick.&lt;/p&gt;

&lt;p&gt;In real world, non-blocking syscalls might block the process and
blocking syscalls might not block at all: it all depends on
implementation details and on the state of the system at run-time.&lt;/p&gt;

&lt;p&gt;Classical examples of blocking system calls are&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;sleep&lt;/code&gt; that should block for a certain number of seconds&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;wait&lt;/code&gt; that could block until a children process exit&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;read&lt;/code&gt; that would block until a chunk of data is available&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;write&lt;/code&gt; that would block on a pipe without enough space for the new data&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;cpu-control-and-time&quot;&gt;CPU control and time&lt;/h2&gt;

&lt;p&gt;Sleep is a very interesting syscall because its whole point is just to
yield the CPU for a while, so that other processes can use it.
Its main use case is to poll for a certain resource to become available
without subtracting computing power that could be used to produce such
resource: it’s a tool for cooperative multitasking in a OS supporting
preemptive multitasking.&lt;/p&gt;

&lt;p&gt;Other blocking system calls (like wait, read and write) depend on
external events to return control to the process.
Soon programmers realized that an external event might never occur
and designed ways to mitigate the risks.&lt;/p&gt;

&lt;p&gt;Unix introduced &lt;a href=&quot;https://en.wikipedia.org/wiki/Signal_(IPC)&quot;&gt;signals&lt;/a&gt;
and services like
&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/functions/alarm.html&quot;&gt;alarm&lt;/a&gt; and
&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/functions/setitimer.html&quot;&gt;setitimer&lt;/a&gt;
to give back control to the calling process on certain events or after
a certain time.&lt;/p&gt;

&lt;p&gt;Later, new syscalls like
&lt;a href=&quot;https://idea.popcount.org/2016-11-01-a-brief-history-of-select2/&quot;&gt;select&lt;/a&gt;,
&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.html&quot;&gt;poll&lt;/a&gt;,
&lt;a href=&quot;https://www.freebsd.org/cgi/man.cgi?query=kqueue&amp;amp;sektion=2&quot;&gt;kqueue&lt;/a&gt; or
&lt;a href=&quot;http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigtimedwait.html&quot;&gt;sigtimedwait&lt;/a&gt;
were introduced with a timeout parameter from the very beginning.&lt;/p&gt;

&lt;h2 id=&quot;plan-9-from-bell-labs&quot;&gt;Plan 9 from Bell Labs&lt;/h2&gt;

&lt;p&gt;Compared to the &lt;a href=&quot;http://man7.org/linux/man-pages/man2/syscalls.2.html&quot;&gt;400 system calls&lt;/a&gt;
of Linux, Plan 9’s &lt;a href=&quot;http://aiju.de/plan_9/plan9-syscalls&quot;&gt;API is rather simpler&lt;/a&gt;
but it still supports a bit of each time-control styles:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://man.9front.org/2/sleep&quot;&gt;sleep&lt;/a&gt; suspends the calling process
for a number of milliseconds specified by the argument.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://man.9front.org/2/sleep&quot;&gt;alarm&lt;/a&gt; causes an
&lt;a href=&quot;http://man.9front.org/2/notify&quot;&gt;alarm note&lt;/a&gt; to be sent to the
invoking process after a number of milliseconds.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://man.9front.org/2/semacquire&quot;&gt;tsemacquire&lt;/a&gt; only waits for a
number of milliseconds to acquire a semaphore.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By design, Plan 9 provides only a very limited support for
non-blocking I/O (through &lt;code class=&quot;highlighter-rouge&quot;&gt;alarm&lt;/code&gt;) and no support for
&lt;a href=&quot;https://notes.shichao.io/unp/ch6/&quot;&gt;I/O multiplexing&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;if a program needs to &lt;strong&gt;wait for several resources&lt;/strong&gt;, it usually calls
&lt;a href=&quot;http://man.9front.org/2/fork&quot;&gt;rfork&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;if a program want to &lt;strong&gt;serve several concurrent clients&lt;/strong&gt;, it usually
expose a &lt;a href=&quot;http://man.9front.org/5/intro&quot;&gt;9P2000 filesystem&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Furthermore, with &lt;a href=&quot;http://man.cat-v.org/9front/2/thread&quot;&gt;libthread&lt;/a&gt;,
Plan 9 provides an implementation of Hoare’s
&lt;a href=&quot;http://www.usingcsp.com/cspbook.pdf&quot;&gt;Communicating Sequential Processes&lt;/a&gt;
in which dedicated (preemptively scheduled) processes are used to issue
any blocking system calls and several cooperatively-scheduled threads
sharing memory in a single process are used to access global state.&lt;/p&gt;

&lt;h1 id=&quot;the-curse-of-frankenstein&quot;&gt;The Curse of Frankenstein&lt;/h1&gt;

&lt;p&gt;The &lt;a href=&quot;https://sourceware.org/bugzilla/show_bug.cgi?id=15819&quot;&gt;complex interactions&lt;/a&gt;
between the different ways to handle timeouts in Unix (and, to a
lesser extent, in Plan 9) are direct effects of its
&lt;a href=&quot;http://marmaro.de/docs/studium/unix-phil/unix-phil.pdf&quot;&gt;design philosophy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As explained by Richard P. Gabriel in
&lt;a href=&quot;https://www.dreamsongs.com/RiseOfWorseIsBetter.html&quot;&gt;his famous essay&lt;/a&gt;,
“Unix and C are the ultimate computer viruses”.&lt;/p&gt;

&lt;h2 id=&quot;worse-is-better-isnt-it&quot;&gt;Worse is better, isn’t it?&lt;/h2&gt;

&lt;p&gt;Worse-is-Better is a model of software design and implementation which
has the following characteristics (in approximately descending order of
importance):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Simplicity&lt;/strong&gt;&lt;br /&gt;
The design must be simple, both in implementation and interface.
It is more important for the implementation to be simple than the
interface. Simplicity is the most important consideration in a design.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Correctness&lt;/strong&gt;&lt;br /&gt;
The design should be correct in all observable aspects, but it is
slightly better to be simple than correct.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Consistency&lt;/strong&gt;&lt;br /&gt;
The design must not be overly inconsistent. Consistency can be
sacrificed for simplicity in some cases, but it is better to drop
those parts of the design that deal with less common circumstances
than to introduce either complexity or inconsistency in the implementation.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Completeness&lt;/strong&gt;&lt;br /&gt;
The design must cover as many important situations as is practical.
All reasonably expected cases should be covered.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Completeness can be sacrificed in favor of any other quality.
In fact, completeness must be sacrificed whenever implementation
simplicity is jeopardized. Consistency can be sacrificed to achieve
completeness if simplicity is retained; especially worthless is
consistency of interface.&lt;/p&gt;

&lt;p&gt;In a way the so called “New Jersey style” was a rush for a
&lt;a href=&quot;https://en.wikipedia.org/wiki/Minimum_viable_product&quot;&gt;minimum viable product&lt;/a&gt;
able to minimize the 
&lt;a href=&quot;https://en.wikipedia.org/wiki/Time_to_market&quot;&gt;time-to-market&lt;/a&gt; and to gain the
&lt;a href=&quot;https://en.wikipedia.org/wiki/First-mover_advantage&quot;&gt;first mover advantage&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Quoting Gabriel&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Both early Unix and C compilers had simple structures, are easy to
port, require few machine resources to run, and provide about 50%-80%
of what you want from an operating system and programming language.&lt;/p&gt;

  &lt;p&gt;[…]&lt;/p&gt;

  &lt;p&gt;It is important to remember that the initial virus has to be basically
good. If so, the viral spread is assured as long as it is portable.
&lt;strong&gt;Once the virus has spread&lt;/strong&gt;, there will be &lt;strong&gt;pressure to improve it&lt;/strong&gt;,
possibly by increasing its functionality &lt;strong&gt;closer to 90%&lt;/strong&gt;, but 
&lt;strong&gt;users have already been conditioned to accept worse&lt;/strong&gt; than the right thing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So far so good.&lt;/p&gt;

&lt;p&gt;Early Unix, like Plan 9, didn’t aim at perfection, but at serving the
majority of users’ need well enough.&lt;/p&gt;

&lt;h2 id=&quot;but-is-enough-enough&quot;&gt;But is “enough”, enough?&lt;/h2&gt;

&lt;p&gt;The Unix philosophy spread beyond Unix, and it became the common wisdom
of software engineering so far.&lt;/p&gt;

&lt;p&gt;For early Unix and Plan 9, enough is enough.
Look at 9front to see a modern system that follows this philosophy consistently.&lt;/p&gt;

&lt;p&gt;There is a catch, however.&lt;br /&gt;
Plan 9 (like early Unix), is a system evolving as a whole.
This is particularly visible in the &lt;a href=&quot;http://code.9front.org/hg/plan9front/&quot;&gt;9front repository&lt;/a&gt;.
The whole system evolves together, all programs are modified consistently,
answering to the ever changing needs of &lt;a href=&quot;http://cat-v.org/&quot;&gt;its users&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Plan 9 is &lt;strong&gt;one&lt;/strong&gt; application of computers.
An operating system split into several executables, but still &lt;strong&gt;one thing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So in its asymptotic path toward completeness, all pieces 
progress together. When they provides 90% of required functionality, it
really means 90%. Or 95%. Or 97%. Or 99%.&lt;/p&gt;

&lt;p&gt;But what if we split the system into independent components and assign
them to different teams following the same philosophy?&lt;/p&gt;

&lt;p&gt;This is what happened to mainstream operating systems.&lt;/p&gt;

&lt;p&gt;With their widespread adoption, the variety of people needs couldn’t be
served anymore by a single company. Thus good APIs and development tools
provided a strategic advantage to build ecosystems of applications that,
by running on a certain OS, would have expanded its market share.&lt;/p&gt;

&lt;p&gt;Unix was particularly well suited for this kind of &lt;strong&gt;race for
application developers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However this process had a significant but overlooked drawback: the
running operating system lose its unity, its coherence.
The operating system became a collection of variegate software,
developed by a variety of different teams, each with their own goals and
taste and set of best practices.&lt;/p&gt;

&lt;h2 id=&quot;more-pieces-more-cracks&quot;&gt;More pieces, more cracks!&lt;/h2&gt;

&lt;p&gt;Take one application that works correctly 99% of times, and you will be 
fine 99% of times.&lt;/p&gt;

&lt;p&gt;But what if you have 10 applications each working correctly 99% of times?&lt;/p&gt;

&lt;p&gt;The probability that they work correctly together at each computer
clock is (99%)^10. That is: their composition will do what you expect 
roughly &lt;strong&gt;90% of times&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With such assumption, the probability of a system behaving correctly
goes down pretty quickly approaching the formula&lt;/p&gt;

&lt;p&gt;&lt;em&gt;p(n) = (0.99)ⁿ&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/graphic/probability_of_correctness.png&quot; alt=&quot;Probability of whole system correctness.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;How many programs are you running right now? :-D&lt;/p&gt;

&lt;p&gt;This is the curse of Frankenstein: more pieces, more cracks.&lt;/p&gt;

&lt;h2 id=&quot;simplex-sigillum-veri&quot;&gt;Simplex Sigillum Veri&lt;/h2&gt;

&lt;p&gt;Plan 9 from Bell Labs followed the New Jersey style from the very
beginning and still does so in most if it’s incarnations.&lt;/p&gt;

&lt;p&gt;But what about Jehanne,
&lt;a href=&quot;https://www.theguardian.com/world/2002/jun/17/humanities.internationaleducationnews&quot;&gt;from Meucci’s laboratory&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;Turns out the design of Jehanne doesn’t follow the New Jersey style.
I have no rush. Yet Jehanne doesn’t follow the MIT/Stanford style either.&lt;/p&gt;

&lt;p&gt;To follow Gabriel’s scheme, we could say that Jehanne is based upon&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Simplicity&lt;/strong&gt;&lt;br /&gt;
The design must be simple. Few simple, easy to learn and orthogonal
abstractions should be able to describe any use case conceivable.&lt;br /&gt;
If the implementation is difficult, the design is not simple enough.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Correctness&lt;/strong&gt;&lt;br /&gt;
The design should be correct in all observable aspects.&lt;br /&gt;
Incorrectness is not allowed.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Consistency&lt;/strong&gt;&lt;br /&gt;
The design must not be inconsistent.
Any inconsistency reveals a design problem: either a missing
abstraction or abstractions that are not orthogonal enough.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Composability&lt;/strong&gt;&lt;br /&gt;
Completeness should naturally emerge as a (desirable) side effect.&lt;br /&gt;
As such, it cannot be a goal: the design must cover as &lt;strong&gt;few&lt;/strong&gt;
important situations as practical and let the user compose the
abstractions provided to build what he needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I call this set of principles &lt;em&gt;simplex sigillum veri&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It’s deeply inspired by the works of other Italian hackers,
such as &lt;a href=&quot;https://en.wikipedia.org/wiki/Antonio_Meucci&quot;&gt;Antonio Meucci&lt;/a&gt;,
&lt;a href=&quot;https://en.wikipedia.org/wiki/Programma_101&quot;&gt;Pier Giorgio Perotto&lt;/a&gt;,
&lt;a href=&quot;https://en.wikipedia.org/wiki/Guglielmo_Marconi&quot;&gt;Guglielmo Marconi&lt;/a&gt;,
&lt;a href=&quot;https://en.wikipedia.org/wiki/Renzo_Piano&quot;&gt;Renzo Piano&lt;/a&gt; and
&lt;a href=&quot;https://en.wikipedia.org/wiki/Leonardo_da_Vinci&quot;&gt;Leonardo da Vinci&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;the-awake-system-call&quot;&gt;The Awake system call&lt;/h1&gt;

&lt;p&gt;Plan 9 supports &lt;strong&gt;39 system calls&lt;/strong&gt; (not counting obsolete ones).
Since some system calls can be expressed in term of the others, in
Jehanne I moved the duplicates in userspace.&lt;/p&gt;

&lt;p&gt;The idea is that a smaller kernel surface makes it easier to get it
right and simple in the long run.&lt;/p&gt;

&lt;p&gt;During such clean up, I realized that &lt;code class=&quot;highlighter-rouge&quot;&gt;sleep&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;alarm&lt;/code&gt; and
&lt;code class=&quot;highlighter-rouge&quot;&gt;tsemacquire&lt;/code&gt; were somehow “ugly”: I supposed that they were mixing
orthogonal issues and looked for the missing abstraction they were hiding.&lt;/p&gt;

&lt;p&gt;This is how the &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt; syscall was born:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;long awake(long milliseconds);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Awake is the complement of &lt;code class=&quot;highlighter-rouge&quot;&gt;sleep&lt;/code&gt;: it &lt;strong&gt;books a new time slice&lt;/strong&gt; in the future.
It’s a fundamental building block that can be used to implement
other services in user space, like &lt;code class=&quot;highlighter-rouge&quot;&gt;sleep&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;alarm&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;tsemacquire&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It interrupts a blocking syscall after a certain number of milliseconds.
On failure it returns &lt;code class=&quot;highlighter-rouge&quot;&gt;0&lt;/code&gt;. On success it returns a negative long that can
be used as an identifier to release the booked time slice.&lt;/p&gt;

&lt;p&gt;On wakeup, no note or signal is sent to the process, the process’ error
string left unchanged: the blocking syscall simply returns to the
process with a &lt;code class=&quot;highlighter-rouge&quot;&gt;~0ULL&lt;/code&gt; result.&lt;/p&gt;

&lt;p&gt;A process can register how many wakeups it want (within a global system cap)
and each wake up will have a chance to interrupt a system call.&lt;/p&gt;

&lt;p&gt;Wakeups are booked in two distinct group that do not interact: normal
process execution and note handlers. Such groups are automatically reset
respectively on &lt;a href=&quot;http://man.cat-v.org/9front/2/exits&quot;&gt;exits&lt;/a&gt; and on
&lt;a href=&quot;http://man.cat-v.org/9front/2/notify&quot;&gt;noted&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In libc,
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/lib/c/9sys/awakened.c&quot;&gt;two very simple functions&lt;/a&gt;
wrap &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt; to enhance readability.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Awakened&lt;/code&gt; tells the calling process whether a certain wakeup already occurred.
&lt;code class=&quot;highlighter-rouge&quot;&gt;Forgivewkp&lt;/code&gt; tells the kernel to remove a certain wakeup.&lt;/p&gt;

&lt;p&gt;With these primitives it’s trivial to move
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/lib/c/9sys/sleep.c&quot;&gt;sleep&lt;/a&gt; and
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/lib/c/9sys/tsemacquire.c&quot;&gt;tsemaquire&lt;/a&gt; to libc.&lt;/p&gt;

&lt;p&gt;In particular, &lt;code class=&quot;highlighter-rouge&quot;&gt;tsemaquire&lt;/code&gt; shows pretty well the simple idiom of awake:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;	/* book a time slice in the future */
	long wkup = awake(ms);
	while(blocking_syscall() == -1){
		if(jehanne_awakened(wkup)){
			/* handle syscall timed out */
		}
		/* the syscall has been otherwise interrupted, you can
		 * - try again
		 * - fail with an error
		 * - do whatever fit
		 */
	}
	/* the syscall completed, release the booked time slice... */
	jehanne_forgivewkp(wkup);

	/* ...and enjoy */
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(the mindful reader will notice that
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/issues/2&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;alarm&lt;/code&gt; is still waiting to be moved to user space&lt;/a&gt;…
the fact is that it’s too boring of a task!)&lt;/p&gt;

&lt;p&gt;To be fair, &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt; was originally designed to interrupt &lt;code class=&quot;highlighter-rouge&quot;&gt;rendezvous&lt;/code&gt; only,
to enable &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/lib/c/9sys/qlock.c&quot;&gt;timeouts support for QLock, RWLock and Rendez&lt;/a&gt;
in libc.&lt;/p&gt;

&lt;p&gt;But from the very beginning it was clear that it could have been
generalized and composed with other system calls, to provide other services.&lt;/p&gt;

&lt;p&gt;With the advent of &lt;a href=&quot;https://github.com/JehanneOS/jehanne/tree/master/sys/src/lib/posix&quot;&gt;libposix&lt;/a&gt;,
I used &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt; to implement support for POSIX
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/lib/posix/files.c&quot;&gt;non-blocking I/O&lt;/a&gt;,
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/lib/posix/processes.c&quot;&gt;signals&lt;/a&gt;
and &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/lib/posix/sigsets.c&quot;&gt;sigset waiters&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Which in turn enabled the port of &lt;a href=&quot;https://jehanne.io/2018/01/06/jehanne-in-2017.html&quot;&gt;newlib&lt;/a&gt; and of
&lt;a href=&quot;http://www.mirbsd.org/permalinks/wlog-10_e20180415-tg.htm&quot;&gt;MirBSD Korn Shell&lt;/a&gt;
to Jehanne.&lt;/p&gt;

&lt;p&gt;All this with more or less &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/kern/port/awake.c&quot;&gt;600 lines of code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Two kernel processes, a &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/kern/port/awake.c#L471&quot;&gt;timer&lt;/a&gt;
and a &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/kern/port/awake.c#L621&quot;&gt;ringer&lt;/a&gt;,
cooperate through a linked list
of wakeups kept &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/kern/port/awake.c#L369&quot;&gt;in order of expiration&lt;/a&gt; 
that is filled by the system calls.
On each &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/kern/port/awake.c#L447&quot;&gt;tick&lt;/a&gt;,
if the first element of the registry is expired, the interrupt
handler awake the timer, that prepare a collection of expired timers.&lt;/p&gt;

&lt;p&gt;Then the ringer start a loop to interrupt the process properly.&lt;/p&gt;

&lt;p&gt;These two different processes make it possible to keep processing new
wakeups while the ringer is waiting for the process to be in an
interruptible state.&lt;/p&gt;

&lt;p&gt;Not &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/master/sys/src/kern/port/awake.c#L76&quot;&gt;all blocking system calls&lt;/a&gt;
can be interrupted though. &lt;code class=&quot;highlighter-rouge&quot;&gt;Create&lt;/code&gt; is a notable example of a blocking
system call that has been excluded from the interruptible ones, to prevent
a timeout to leave an orphan file behind.&lt;/p&gt;

&lt;h1 id=&quot;issues-and-future-uses&quot;&gt;Issues and future uses&lt;/h1&gt;

&lt;p&gt;Awake will be used to implement all timeouts of Jehanne’s system calls.&lt;/p&gt;

&lt;p&gt;Even without libposix, it provides a simple mechanism to implement
non-blocking I/O, if needed.&lt;/p&gt;

&lt;p&gt;And it will be used to implement timeouts in multiplexing I/O too.&lt;/p&gt;

&lt;p&gt;Unfortunately, as an interface to the kernel scheduler, &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt; doesn’t
work with user space schedulers that keep control of their own tasks.
Right now, this just means that &lt;code class=&quot;highlighter-rouge&quot;&gt;qlockt&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;rlockt&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;wlockt&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;rsleept&lt;/code&gt;
cannot work when linking libthread. In the long run, it might make slightly
more difficult to port virtual machines and programming languages that 
provide their own scheduler in user space, like Go or Java.&lt;/p&gt;

&lt;p&gt;The solution however is already outlined by libthread usage of a custom 
&lt;code class=&quot;highlighter-rouge&quot;&gt;rendezvous&lt;/code&gt;: we will simply override the system call to give control to
the desired scheduler.&lt;/p&gt;
</content>
  </entry>
    
  
  
  

  <entry>
    <id>https://jehanne.io/2018/04/16/mksh-on-jehanne</id>

    <title>Mksh on Jehanne</title>
    <updated>2018-04-16T00:00:00+00:00</updated>
    <author>
        <name>Giacomo Tesio</name>
        
    </author>
    <content type="html">&lt;p&gt;A little history about MirBSD’s Korn Shell and Jehanne, kindly hosted
by &lt;a href=&quot;http://www.mirbsd.org/permalinks/wlog-10_e20180415-tg.htm&quot;&gt;MirBSD&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
    
  
  
  

  <entry>
    <id>https://jehanne.io/2018/01/06/jehanne-in-2017</id>

    <link type="text/html" rel="alternate" href="/2018/01/06/jehanne-in-2017.html"/>

    <title>Jehanne in 2017</title>
    <updated>2018-01-06T00:00:00+00:00</updated>
    <author>
        <name>Giacomo Tesio</name>
        
    </author>
    <content type="html">&lt;p&gt;Another year is gone with Jehanne.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/graphic/screenshot-20180106.png&quot; target=&quot;_blank&quot; title=&quot;Jehanne, click to enlarge&quot;&gt;
	&lt;img src=&quot;/graphic/screenshot-20180106.png&quot; style=&quot;width: 600px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is a little report of what has been done (in no particular order):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;everybody’s copyrights have been made explicit and hopefully correct&lt;/li&gt;
  &lt;li&gt;several bugs have been fixed (and probably more introduced)&lt;/li&gt;
  &lt;li&gt;kernel options management has been simplified&lt;/li&gt;
  &lt;li&gt;boot assembly has been rewritten&lt;/li&gt;
  &lt;li&gt;swap support have been removed&lt;/li&gt;
  &lt;li&gt;MCACHE support for mount has been removed&lt;/li&gt;
  &lt;li&gt;various improvements have been imported from 9front (MMU management,
PCI, AHCI, interruptible locks…) and 9front’s pstree has been ported&lt;/li&gt;
  &lt;li&gt;the &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt; system call has been generalized to interrupt several
blocking syscalls, even during note handling&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;tsemacquire&lt;/code&gt; has been moved to libc (in less than
&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/79f8204/sys/src/lib/c/9sys/tsemacquire.c#L22-L36&quot;&gt;15 lines&lt;/a&gt;)&lt;/li&gt;
  &lt;li&gt;no &lt;code class=&quot;highlighter-rouge&quot;&gt;rendezvous&lt;/code&gt; can occur at the tag ~0&lt;/li&gt;
  &lt;li&gt;the names of the procedures provided by the native C library has been
prefixed with “jehanne_”, to define a namespace that avoid collisions
with other C libraries (so that new programs can use for example
both a POSIX C library and the Jehanne’s libc)&lt;/li&gt;
  &lt;li&gt;the name space of a process you own can be cloned writing “clone”
to its /proc/$pid/ns&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/8ed3e74c3fa05fcbdd985fb3de59e9baee38f12f/sys/src/lib/posix/environment.c&quot;&gt;LibPOSIX&lt;/a&gt;
has been introduced&lt;/li&gt;
  &lt;li&gt;RedHat’s newlib has been ported to Jehanne on top of LibPOSIX&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://mirbsd.de/mksh&quot;&gt;MirBSD Korn Shell&lt;/a&gt; has been ported
to Jehanne on top of newlib&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of these changes are more heretic than others, but all are designed
to make the system simpler and more useful at the same time.&lt;/p&gt;

&lt;p&gt;The generalization of awake allows the implementation in userspace
of a wide range of features usually found in unix kernels.&lt;br /&gt;
For example, LibPOSIX can use it to provide non blocking I/O and to
implement sigtimedwait.&lt;/p&gt;

&lt;p&gt;The removal of swap and mount(MCACHE) simplifies the kernel
and increases security.&lt;/p&gt;

&lt;h1 id=&quot;mirbsd-korn-shell&quot;&gt;MirBSD Korn Shell&lt;/h1&gt;

&lt;p&gt;Despite the various tests I wrote for newlib, I wanted a real world
application to check the quality of LibPOSIX.&lt;/p&gt;

&lt;p&gt;I choose &lt;a href=&quot;http://mirbsd.de/mksh&quot;&gt;mksh&lt;/a&gt; for two reasons:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;it’s simple and powerful&lt;/li&gt;
  &lt;li&gt;it’s developed by a great hacker that
&lt;a href=&quot;https://github.com/MirBSD/mksh/commit/9f3c0efefcc086f42dc31eca3a5b4d101cf6c85c&quot;&gt;actively helped me&lt;/a&gt;
even to understand the weird semantics I had to implement&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thanks Thorsten!&lt;/p&gt;

&lt;p&gt;If you want to give it a try, run in rio: &lt;code class=&quot;highlighter-rouge&quot;&gt;vt sys/posixly mksh -l&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;(to get rio on boot: &lt;code class=&quot;highlighter-rouge&quot;&gt;cp /arch/rc/lib/startup/terminal /cfg/startup&lt;/code&gt;)&lt;/p&gt;

&lt;h1 id=&quot;new-years-resolutions-for-2018&quot;&gt;New year’s resolutions for 2018&lt;/h1&gt;

&lt;h2 id=&quot;funny-ones&quot;&gt;Funny ones:&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;del&gt;keep stealing from 9front&lt;/del&gt; improve hardware support&lt;/li&gt;
  &lt;li&gt;add O_NONBLOCK support to LibPOSIX (and newlib) on top of the &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt;
system call&lt;/li&gt;
  &lt;li&gt;draft the new file protocol that will replace both HTTP and 9P2000&lt;/li&gt;
  &lt;li&gt;move the existing 9P2000 server to this new protocol&lt;/li&gt;
  &lt;li&gt;create new file servers to read/write at least Linux Ext2 and NTFS
with the new protocol&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;duties&quot;&gt;Duties:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;write about the &lt;code class=&quot;highlighter-rouge&quot;&gt;awake&lt;/code&gt; system call (as promised one year ago)&lt;/li&gt;
  &lt;li&gt;write &lt;del&gt;what I want to forget&lt;/del&gt; about LibPOSIX&lt;/li&gt;
  &lt;li&gt;write or port a package manager&lt;/li&gt;
  &lt;li&gt;port GCC and friends on top of newlib/LibPOSIX&lt;/li&gt;
  &lt;li&gt;turn Jehanne in a self-hosted OS&lt;/li&gt;
  &lt;li&gt;write documentation and manual&lt;/li&gt;
  &lt;li&gt;add screenshots to the website&lt;/li&gt;
  &lt;li&gt;more tests&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;under-evaluation&quot;&gt;Under evaluation:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;port pkgsrc&lt;/li&gt;
  &lt;li&gt;port &lt;a href=&quot;http://www.pell.portland.or.us/~orc/Code/discount/&quot;&gt;discount&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;port musl&lt;/li&gt;
  &lt;li&gt;port ncurses&lt;/li&gt;
  &lt;li&gt;port vim&lt;/li&gt;
  &lt;li&gt;port &lt;a href=&quot;http://miasap.se/obnc/&quot;&gt;OBNC&lt;/a&gt; (and replace Go with Wirth’s Oberon-07)&lt;/li&gt;
  &lt;li&gt;port… more Free Software&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;boring-task&quot;&gt;Boring task:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;write the equivalent of lib9p for the new file protocol&lt;/li&gt;
  &lt;li&gt;write an alarm file server on top of the new file protocol and remove
&lt;code class=&quot;highlighter-rouge&quot;&gt;alarm&lt;/code&gt; from the kernel&lt;/li&gt;
  &lt;li&gt;fix bugs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;real-promises&quot;&gt;Real promises:&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;more crazy ideas&lt;/li&gt;
  &lt;li&gt;break the build&lt;/li&gt;
  &lt;li&gt;sleep&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Who guess what will be actually done?&lt;/p&gt;
</content>
  </entry>
    
  
  
  

  <entry>
    <id>https://jehanne.io/2017/01/20/hacking</id>

    <link type="text/html" rel="alternate" href="/2017/01/20/hacking.html"/>

    <title>Hacking</title>
    <updated>2017-01-20T00:00:00+00:00</updated>
    <author>
        <name>Giacomo Tesio</name>
        
    </author>
    <content type="html">&lt;p&gt;I’ve just published the &lt;a href=&quot;https://jehanne.io/doc/hacking/overview.html&quot;&gt;Hacking section of the manual&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Hacking Jehanne is simple and funny!&lt;/p&gt;

&lt;p&gt;Give it a try!&lt;/p&gt;

</content>
  </entry>
    
  
  
  

  <entry>
    <id>https://jehanne.io/2017/01/06/a-year-with-jehanne</id>

    <link type="text/html" rel="alternate" href="/2017/01/06/a-year-with-jehanne.html"/>

    <title>A year with Jehanne</title>
    <updated>2017-01-06T00:00:00+00:00</updated>
    <author>
        <name>Giacomo Tesio</name>
        
    </author>
    <content type="html">&lt;p&gt;One year ago today, an heretic approach to Plan 9’s legacy was born.&lt;/p&gt;

&lt;p&gt;I wanted a simple, secure and distributed operating system for programmers.&lt;/p&gt;

&lt;p&gt;Today Jehanne looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/graphic/screenshot-20170106.png&quot; target=&quot;_blank&quot; title=&quot;Jehanne, click to enlarge&quot;&gt;
	&lt;img src=&quot;/graphic/screenshot-20170106.png&quot; style=&quot;width: 600px&quot; /&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A lot of work has been done to turn Jehanne from a vision to a runnable starting point, but a little baby cannot be scary!&lt;/p&gt;

&lt;h2 id=&quot;a-pursuit-of-simplicity&quot;&gt;A pursuit of simplicity&lt;/h2&gt;

&lt;p&gt;The first goal of Jehanne is to be a &lt;strong&gt;simple&lt;/strong&gt; operating system.&lt;/p&gt;

&lt;p&gt;Defining &lt;a href=&quot;https://plato.stanford.edu/entries/simplicity/&quot;&gt;simplicity&lt;/a&gt; is hard, but it is a prerequisite for security and usually seems obvious only in retrospect.&lt;/p&gt;

&lt;p&gt;As a first step toward this goal I have removed or replaced most of code that Harvey inherited from the &lt;a href=&quot;https://github.com/brho/plan9&quot;&gt;Berkeley distribution of Plan 9&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Jehanne derives its kernel from Charles Forsyth’s &lt;a href=&quot;https://bitbucket.org/forsyth/plan9-9k&quot;&gt;Plan9-9k&lt;/a&gt; instead of the &lt;a href=&quot;https://code.google.com/archive/p/nix-os/&quot;&gt;Nix&lt;/a&gt; one imported in Harvey&lt;/li&gt;
  &lt;li&gt;it adopts the &lt;a href=&quot;http://www.unix.org/version2/whatsnew/lp64_wp.html&quot;&gt;LP64&lt;/a&gt; programming model (Plan 9 is LLP64 on x86_64)&lt;/li&gt;
  &lt;li&gt;many syscalls have been moved to user space or simply removed (and more will go)&lt;/li&gt;
  &lt;li&gt;the real-time scheduler has been removed&lt;/li&gt;
  &lt;li&gt;the compiler has been outsourced&lt;/li&gt;
  &lt;li&gt;most user space tools that are not required for a minimal OS has been removed (as they are going to be distributed as packages)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What remains has been modified in several ways and more drastic changes are coming. However, despite the changes and the removals, Jehanne still inherit most of its code from its noble ancestors.&lt;/p&gt;

&lt;h2 id=&quot;major-thefts&quot;&gt;Major thefts&lt;/h2&gt;

&lt;p&gt;First, all credit should go to Bell Labs for creating Plan 9 and authorizing the University of California to distribute the 4th version of Plan 9 as GPLv2. While the Jehanne’s kernel comes from a different source, obviously no Plan 9 derivative would exist without the original.&lt;/p&gt;

&lt;p&gt;Second I have to thanks Charles Forsyth for his &lt;a href=&quot;https://bitbucket.org/forsyth/plan9-9k&quot;&gt;Plan9-9k&lt;/a&gt; that rescued me from the “complexities” of Nix and is &lt;a href=&quot;https://bitbucket.org/forsyth/plan9-9k/src/dde8e6496a1a5478cc8347661f6f5d2840495d39/NOTICE?at=default&amp;amp;fileviewer=file-view-default&quot;&gt;licensed as GPLv2+&lt;/a&gt;. Porting it to GCC has been way easier than fixing Nix memory management (and believe me, I tried really hard!).&lt;/p&gt;

&lt;p&gt;Then comes the &lt;a href=&quot;https://github.com/Harvey-OS/harvey/graphs/contributors&quot;&gt;Harvey’s team&lt;/a&gt; that actually let me play with a great project for a while and patiently guided me in the world of OS development. The build tools in Jehanne are evolutions of the Harvey’s original ones and also some userspace tools and a few assembly bits evolved from there.&lt;/p&gt;

&lt;p&gt;And I should thanks the 9front developers (particularly &lt;a href=&quot;http://felloff.net/usr/cinap_lenrek/&quot;&gt;Cinap Lenrek&lt;/a&gt; and &lt;a href=&quot;http://aiju.de/&quot;&gt;Julius Schmidt&lt;/a&gt;) since my rule of thumb is “when in doubt, copy 9front”.&lt;br /&gt;
Yes, I know… I should have more doubts! :-D&lt;br /&gt;
Their impact on Jehanne is deeper than they might want to admit:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;I ported 9front’s devshr, its usb stack, its awk and several other piece of code to Jehanne&lt;/li&gt;
  &lt;li&gt;I choosed hjfs as the default storage in Jehanne and used it to boot Jehanne on real hardware from usb&lt;/li&gt;
  &lt;li&gt;whenever I hit a bug in the original code from Plan 9, I check how it has been addressed in 9front&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally thanks should go to &lt;a href=&quot;http://www.quanstro.net/&quot;&gt;Erik Quanstrom&lt;/a&gt; (&lt;a href=&quot;http://www.9atom.org/&quot;&gt;9atom&lt;/a&gt;’s author) and to &lt;a href=&quot;https://github.com/0intro&quot;&gt;David du Colombier&lt;/a&gt; (&lt;a href=&quot;http://www.9legacy.org/&quot;&gt;9legacy&lt;/a&gt;’s maintainer) as they influenced this project in several ways. And obviously, to &lt;a href=&quot;http://marc.info/?l=9fans&quot;&gt;9fans&lt;/a&gt;, who answer to my crazy questions with their usual humor and wisdom!&lt;/p&gt;

&lt;h1 id=&quot;so-how-did-you-wasted-your-time-so-far&quot;&gt;So… how did you wasted your time so far?&lt;/h1&gt;

&lt;p&gt;In 2016 I worked on several aspects of the project, fixing old bugs and adding tons of new ones. It would be impossible to describe each change or decision in a single post. Here you can just find an overview of the largest activities (that I can remember tonight :-D).&lt;/p&gt;

&lt;h2 id=&quot;dont-panic&quot;&gt;Don’t panic!&lt;/h2&gt;

&lt;p&gt;First I worked on &lt;a href=&quot;https://github.com/JehanneOS/devtools/&quot;&gt;development tools&lt;/a&gt; to minimize the cost for newcomers to try and start hacking with Jehanne.&lt;/p&gt;

&lt;p&gt;On Debian GNU/Linux you can see Jehanne in action with very few commands:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install git golang build-essential flex bison qemu-system
git clone https://github.com/JehanneOS/jehanne.git
cd jehanne
git submodule init                               # we have a lot of submodules
git submodule update --init --recursive --remote
./hacking/devshell.sh                            # start a shell with appropriate environment
./hacking/continuous-build.sh                    # to build everything
./hacking/runOver9P.sh                           # to start the system in QEMU
./hacking/drawterm.sh                            # in another shell, password: demodemo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The first build will take a while downloading and building the cross-compiling tool chain (GCC, binutils, autotools…), but the following ones will be matter of minutes (or even seconds if you build a single component).&lt;/p&gt;

&lt;h2 id=&quot;mess-up-the-kernel&quot;&gt;Mess up the kernel&lt;/h2&gt;

&lt;p&gt;One of the most challenging aspect of Jehanne’s development so far has being cleaning up and modernize the kernel code (and a lot of work is still to be done!).&lt;/p&gt;

&lt;p&gt;Now, I know that Plan 9 has been written by programmers that are way better than me, but hey! Jehanne has to be heretic!&lt;/p&gt;

&lt;p&gt;To my untrained eye, the Plan 9 design is great, but the actual implementation sucks in several places. And that’s fine: Plan 9 is a &lt;strong&gt;research&lt;/strong&gt; operating system! Indeed you can find in Jehanne warnings like &lt;em&gt;“&lt;a href=&quot;https://github.com/brho/plan9/blob/89d43d2262ad43eb4b26c2a8d6a27cfeddb33828/sys/src/9/pc/pci.c#L10-L13&quot;&gt;needs a massive rewrite&lt;/a&gt;”&lt;/em&gt; that were inherited from the Bell Lab’s code and that will stay untouched for a while.&lt;/p&gt;

&lt;p&gt;But to me, the main issue is that the various components are tightly coupled. &lt;strong&gt;Very&lt;/strong&gt; tightly coupled. Since we are going to port several useful unix tools to Jehanne, decoupling will be a leitmotif of its development.&lt;/p&gt;

&lt;p&gt;A first example was &lt;em&gt;_tos&lt;/em&gt; (top of stack) that coupled the kernel, the profiling machinery and libc.
In Jehanne all this is gone: when we will have a profiler, it will be served as a filesystem.&lt;/p&gt;

&lt;p&gt;A more subtle example is how Plan 9’s system API is coupled with 9P: for example &lt;em&gt;open()&lt;/em&gt;’s mode constants (&lt;em&gt;OREAD&lt;/em&gt;, &lt;em&gt;OWRITE&lt;/em&gt;…) are the same in &lt;em&gt;libc.h&lt;/em&gt; and in the protocol.&lt;br /&gt;
To allow new protocols to be integrated in Jehanne as deeply as 9P, I moved all 9P related defines from &lt;em&gt;libc.h&lt;/em&gt; to &lt;em&gt;9P2000.h&lt;/em&gt;, I defined new constants (&lt;em&gt;NP_OREAD&lt;/em&gt;, &lt;em&gt;NP_OWRITE&lt;/em&gt;…) and changed the values in &lt;em&gt;libc.h&lt;/em&gt;. It has been a nightmare, but now I will be able to experiment with new protocols way easier.
Finally I renamed &lt;em&gt;devmnt&lt;/em&gt; as &lt;em&gt;dev9p&lt;/em&gt; to clarify that 9P2000 will be only one among the protocols supported.&lt;/p&gt;

&lt;p&gt;To enhance their encapsulation, I rewrote the modules related to the userspace memory. After that, debugging memory-related issues with gdb turned way easier. Several other areas require similar efforts but they have lower priority.&lt;/p&gt;

&lt;p&gt;Finally I removed the real-time scheduler. It was not that bad, but frankly when I need a real time OS I use QNX, and its presence was actually imposing an higher complexity to other areas of the system (for example &lt;em&gt;devproc&lt;/em&gt; and &lt;a href=&quot;https://swtch.com/semaphore.pdf&quot;&gt;semaphores&lt;/a&gt;).&lt;/p&gt;

&lt;h2 id=&quot;shrink-its-surface&quot;&gt;Shrink its surface&lt;/h2&gt;

&lt;p&gt;An obvious requirement of an operating system striving for simplicity is to have a minimum number of orthogonal system calls, so that the user space tools and the kernel can evolve independently.&lt;/p&gt;

&lt;p&gt;As previously stated, I moved to libc several syscalls (and more are going to be moved in the near future). Some of them are implemented with files from classic devices (eg &lt;em&gt;dup&lt;/em&gt; or &lt;em&gt;nsec&lt;/em&gt;). For others, like &lt;em&gt;chdir&lt;/em&gt;, &lt;em&gt;brk&lt;/em&gt; and &lt;em&gt;pipe&lt;/em&gt;, a new device called &lt;em&gt;devself&lt;/em&gt; has been introduced. Some syscalls have changed their semantics or their behaviour, like &lt;em&gt;open&lt;/em&gt;, &lt;em&gt;create&lt;/em&gt; and &lt;em&gt;rendezvous&lt;/em&gt;. Others have been simply removed, as &lt;em&gt;sleep&lt;/em&gt;, &lt;em&gt;stat&lt;/em&gt;, &lt;em&gt;wstat&lt;/em&gt; and &lt;em&gt;sysr1&lt;/em&gt;. The most fortunate one, &lt;em&gt;alarm&lt;/em&gt;, is waiting to be turned to a file server from day one, but stay untouched in kernel because of lack of time.&lt;/p&gt;

&lt;p&gt;This is still a work in progress and I’m not sure about what will be the final number of syscalls in the system (or even their signatures). Fortunately it doesn’t matter: what I want is a clean and simple system API, free from backward compatibility issues but still able to support modern software.&lt;/p&gt;

&lt;p&gt;Indeed I even added a new system call, &lt;em&gt;awake&lt;/em&gt;, that deserves a separate post as an iconic example of how a well designed API can both simplify and empower the system.&lt;/p&gt;

&lt;h2 id=&quot;poison-traditions&quot;&gt;Poison traditions&lt;/h2&gt;

&lt;p&gt;One of the first and most heretic decision I made has been to rethink the default namespace organization (aka &lt;a href=&quot;https://wiki.linuxfoundation.org/lsb/fhs&quot;&gt;filesystem hierarchy standard&lt;/a&gt; in Linux’s parlance).&lt;/p&gt;

&lt;p&gt;Now, I know that with &lt;em&gt;bind&lt;/em&gt; and &lt;em&gt;mount&lt;/em&gt; you can shape your namespace as you like. I know, Plan 9 is not Unix!&lt;/p&gt;

&lt;p&gt;But think of &lt;em&gt;/bin&lt;/em&gt;: when UNIX was born most programs were binaries, but now?
We have plenty of scripts there! Thus, in Jehanne, all programs are in &lt;em&gt;/cmd&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;There is no technical reason for this change, but why should we stick to obsolete names and conventions when we can change them for the better? When you realize this, many other changes arise. The default namespace should minimize name collision to ease navigation. It should be coherent and intuitive.&lt;/p&gt;

&lt;p&gt;Again, the current shape of the &lt;strong&gt;default&lt;/strong&gt; namespace shows just a first exploration in the solution’s space, it could change in the future, but I wanted to break it so that we can make it better.&lt;/p&gt;

&lt;h1 id=&quot;what-now&quot;&gt;What now?&lt;/h1&gt;

&lt;p&gt;Now we have a &lt;strong&gt;starting point&lt;/strong&gt;.
Small and full of bugs, but it runs on real hardware.&lt;/p&gt;

&lt;p&gt;What Jehanne is going to become is up to us.&lt;/p&gt;

&lt;p&gt;We don’t need it: Linux, BSDs and Windows are out there and we can use them for &lt;del&gt;fun and&lt;/del&gt; profit.&lt;/p&gt;

&lt;p&gt;Nevertheless I &lt;strong&gt;want&lt;/strong&gt; it.&lt;/p&gt;

&lt;p&gt;I want a system designed for this century.&lt;br /&gt;
A clean, coherent and secure operating system.&lt;br /&gt;
A system for which I don’t need browsers to host apps.&lt;/p&gt;

&lt;p&gt;It might well be just a daydream, but my &lt;a href=&quot;https://github.com/JehanneOS/jehanne&quot;&gt;nightly journey&lt;/a&gt; continues.&lt;/p&gt;

</content>
  </entry>
    
  
  
  

  <entry>
    <id>https://jehanne.io/2016/01/06/jehanne-operating-system</id>

    <link type="text/html" rel="alternate" href="/2016/01/06/jehanne-operating-system.html"/>

    <title>Jehanne Operating System</title>
    <updated>2016-01-06T00:00:00+00:00</updated>
    <author>
        <name>Giacomo Tesio</name>
        
    </author>
    <content type="html">&lt;p&gt;Jehanne is a new distributed operating system designed for programmers.&lt;br /&gt;
The core values that lead the development are &lt;a href=&quot;http://plato.stanford.edu/entries/simplicity/&quot; title=&quot;What is simplicity?&quot;&gt;simplicity&lt;/a&gt; and security.&lt;/p&gt;

&lt;p&gt;Jehanne is a fork of &lt;a href=&quot;http://harvey-os.org&quot; title=&quot;Harvey OS&quot;&gt;Harvey&lt;/a&gt; (which in turn is a fork of 
&lt;a href=&quot;https://github.com/brho/plan9&quot; title=&quot;UC Berkeley release of Plan 9 under the GPLv2&quot;&gt;Plan 9 from Bell Labs&lt;/a&gt; merged with &lt;a href=&quot;https://github.com/rminnich/nix-os&quot;&gt;Nix&lt;/a&gt;’s kernel sources) but
diverges from the design and conventions of its ancestors whenever
they are at odds with its goals.&lt;/p&gt;

&lt;p&gt;For this reason the project is named after the famous French heretic &lt;a href=&quot;https://en.wikipedia.org/wiki/Joan_of_Arc&quot; title=&quot;Jeanne d'Arc&quot;&gt;Joan of Arc&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;/h2&gt;

&lt;p&gt;Jehanne is &lt;a href=&quot;https://github.com/JehanneOS/jehanne/blob/wip/LICENSE.md&quot; title=&quot;A summary of Jehanne licensing&quot;&gt;free software&lt;/a&gt;. Sources are available on &lt;a href=&quot;https://github.com/JehanneOS/jehanne/&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

</content>
  </entry>
    
  
 
</feed>
