Skip to main content

Isolates

An isolate is a running program's own world: its memory, the static data it runs against, and the work running in it. Nothing outside an isolate can reach into it, and in V0 every program runs as exactly one.

A device, the process it runs, and the isolates inside the processThe device is the board and Nylon OS: its cores, memory, pins, USB and Wi-Fi. It keeps running between runs, and starts each run's process. Inside it, the process is the Nylon VM, started for a run with its main isolate and torn down when that isolate ends. Inside the process, the main isolate is your program: its heap, its static data, its resources and the work running in it. Beside it, two more isolates are drawn dashed, for after V0.DeviceThe board and Nylon OS: cores, memory,pins, USB, Wi-Fi. Keeps running betweenruns, and starts each run's process.ProcessThe Nylon VM, started for a run withits main isolate. Torn down when it ends.main isolateyour program:· its heap· static data· resources· work running in itisolateafter V0isolateafter V0

When the main isolate ends, by finishing or by a fault, its process is torn down. The board keeps running, ready for the next run.

Isolates share nothing. A call between them copies a message.

That's why a program's build file starts with IsolateAssemblyBuild: what it builds is an isolate. A library builds code for isolates to use, and doesn't run by itself. Assemblies has the details.

What an isolate owns​

  • Its heap. Every instance the program makes lives on its isolate's heap, and only that isolate's work allocates from it. Memory management says how it's reclaimed.
  • Its static data. Top-level values and a program's links to its libraries belong to the isolate, so two isolates never share one.
  • Its resources. Resources.data gives the isolate its own copy of a file the program ships.

When something goes wrong​

In V0, a fault ends the run. Reading past the end of an array, dividing an integer by zero, overflowing the stack and running out of heap are all faults, and each one ends the isolate at once, wherever in the program it happened. Its process is torn down with it.

The board keeps running. A fault ends your program, not the system under it, so the board reports which fault it was, and you can run again without restarting it.

Exception support comes in V1, so a program can catch a fault and carry on.

More than one isolate​

A V0 program is one isolate, and can't start another yet. When it can, isolates stay apart: a call from one to another copies what it carries, and no reference to an instance ever crosses. Messages are the form data takes on the way.