

Implementing fork() on the Mill CPU (2014) - adamnemecek
http://lackingrhoticity.blogspot.com/2014/07/implementing-fork-on-mill-cpu.html

======
JoeAltmaier
Not just fork, also shared libraries of any kind? Any time multiple processes
share the same virtual addresses. Because shared TLB.

~~~
marcosdumay
Shared libraries are easier. Both processes just use the same memory.

The problem here is page reusing with copy-on-write. I have no idea how one'd
implement that.

~~~
ChuckMcM
This is what I was thinking as well. Single address space OSes are actually
quite powerful, and fork is 'trivial' if you have the correct page protection
mechanisms. Basically a fork consists of starting a new process context, and
each page that gets modified, gets a new page where internal pointers in the
page are updated and external pointers are left alone. The trick there is
managing a list of relocatable references for every page with tags of
'internal' or 'external' to facilitate fixups.

~~~
JoshTriplett
In particular, a single address space means that if you copy a page on write,
you also have to copy any page that points to it, so that you can fix up
pointers to it. And that's not transparent to userspace. With virtual address
spaces, you can copy a page in physical memory without changing its virtual
address.

Then again, many of the same considerations apply when using ASLR.

~~~
comex
In practice, it'd be quite different because with ASLR, the compiler records
the locations of all address references in the binary, so the OS knows what to
fix up. At runtime, though, C programs normally leave no indication in memory
of what is a pointer and what is pure data; even if you changed the compiler
to emit this and the allocator to track it, you'd have problems with fairly
common constructions like custom allocators, unions where it may be nontrivial
to determine which alternative is in use (especially since the data may
actually be uninitialized), tagged pointers, hashes based on the pointer
value, et cetera. Garbage collectors for C run into the same problems and
forbid some of those constructions, but they can always fall back on not
collecting an allocation if they're unsure whether a reference to it is a real
pointer or just an integer with the same value. If you're actually relocating
things, you can't risk accidentally changing the value of some integer.

Honestly, I don't expect such a scheme to be implemented, considering how
complicated (and limited) it would be. It sounds more realistic to implement a
scheme that implements the full semantics even if at a severe performance
cost, as suggested in the article, and expect ported Mill programs to stop
using fork without exec for anything important.

------
tinco
Probably being way ahead of things, but is the instruction set defined at this
point? I would love to play around on an emulator. I browsed around their
website a bit, but saw only youtube videos explaining general information,
same for the white paper.

~~~
peterfirefly
The Wiki on their page contains more information, including this:

[http://millcomputing.com/wiki/Instruction_Set](http://millcomputing.com/wiki/Instruction_Set)

[http://millcomputing.com/instructions.html](http://millcomputing.com/instructions.html)

[http://millcomputing.com/wiki/Architecture](http://millcomputing.com/wiki/Architecture)

The comp.arch newsgroup and the realwordtech web site contain have plenty of
discussion of the Mill. Search for 'Ivan Godard' or 'igodard'.

[http://www.realworldtech.com/forum/?threadid=147612&curposti...](http://www.realworldtech.com/forum/?threadid=147612&curpostid=147612)

[http://www.realworldtech.com/forum/?threadid=147482&curposti...](http://www.realworldtech.com/forum/?threadid=147482&curpostid=147482)

[http://www.realworldtech.com/forum/?threadid=147185&curposti...](http://www.realworldtech.com/forum/?threadid=147185&curpostid=147231)

Some details of the architecture have not been revealed yet due to patents
having to be filed for first, so the public information is incomplete in
places. Other things have been changed recently. Threading and IPC is an
example of the former and the way vectors work is an example of the latter
(and maybe also the former). Both are scheduled to be revealed April 10 in
Amsterdam:

[http://awesomeit.nl/](http://awesomeit.nl/)

Some of the encoding details are also not finalized yet or they might be very
incompletely described. The basic shape of the beast is there, though.

There is no public emulator but there is almost enough information that you
can at least start writing your own for fun.

