Tuesday, October 9, 2018

Actor-based programming language called "X"

Hi!

Though there have been no blog posts on the actual development on ttOS, I have been doing some off-and-on work on it. There have been too many changes for me to write them all down, but I can show you this screenshot of the "changelog" output:


It looks very different than the last blogpost, where ttOS was still in text mode, so a lot has changed both visually and internally. I swapped out my old hand-crafted heap allocator for Doug Lea's dlmalloc heap allocator, and received a tremendous speed increase with it.

Another major step in the direction I want to take this project is the X programming language. The version you see in the screenshot above has a fairly complete implementation of my compiler and VM. Actually, the command line interface is implemented using X.

So, what is X?


I am a very big fan of the actor model. Actually, I use it in one of my bigger projects with which I hope to one day earn some money. What it boils down to, is that you can spawn so-called actors, which are autonomous, isolated "mini-processes". Each actor has its own mailbox, and each can send and receive messages to other actors. An actor's state is stored in the context of itself, so the state can only be modified by sending it a message. This has a tremendous positive effect on potential concurrency problems like race conditions!

Another benefit is that the actor model allows for very sophisticated error handling: the actor system (i.e. the collection of all actors within a certain system) is made up of a single tree. Each actor (except for the root actor) is always a child of another actor. Through a process called escalation, a child actor notifies the parent of any exceptions that occur within its execution, and the parent can decide which course of action to take. Some strategies are to simply restart the actor (and its state), or to escalate the exception up to the parent of the parent.

If you want to know more about the actor model, you can visit the Wikipedia article, or the Akka project (which I use the .NET port of, Akka.NET).

Code Example

Of course, you want to see how the code looks. This is the code for the console, which is an actor in itself. It receives commands from the terminal widget, and then executes it. It's still pretty rough, but already works very nicely.



The dollar commands you see are called "DolDoc routines". I got inspired by Terry Davis' TempleOS, and decided to implement a subset of it in order to add some graphical spunk to the console.

What's next?

Currently, I am working on a garbage collector. Right now it only ever allocates objects, but never frees them. Fun for now, but not so fun when it is going to actually do something in the future. And writing a garbage collector is fun anyway :).

I also want to add introspection and attributes/annotations to the language.

Stay tuned for more. Don't know when though.

Thursday, June 8, 2017

COMBOOT serial boot loader

Contrary to what you might believe from the scarcity of updates on my blog, I have been avidly working on my operating system. I added a bytecode interpreter/VM to it so it will host completely sandboxed executables. But, I will write a separate blog post on that subject later.

What I want to write about now is my COMBOOT serial boot loader. I have a physical laptop lying around that I often use to test whether my OS still runs on physical hardware. However, the booting process is tedious: I use pxelinux to serve my kernel over PXE. First of all, the laptop's PXE ROM is slow,  and second, there is a weird bug in pxelinux regarding sizes of multiboot modules.

I have a small holiday right now, so I decided to write a replacement bootloader that should be able to load my kernel over the serial port. To my knowledge, there isn't a boot loader available that does this. The source code of the COMBOOT project can be found on my GitHub page: https://github.com/dseller/comboot/

Below you can see a short video of it in action:


As well as a screenshot of the bootsrv Windows application doing its thing:


Monday, May 16, 2016

ttOS R0.3

I decided that it's time for the R0.3 release. I don't feel like writing a very lengthy post today, but I want to highlight some things.

  • Multitasking
  • Logging
  • BASIC interpreter

Saturday, May 7, 2016

vhdutil - attaching/detaching VHD files using the command line

I just published a small tool to my Github account. While developing ttOS, I have been struggling to find a virtual hard disk format that:

  1. Is compatible with most x86 virtual machines
  2. Can be written to a device (USB stick, cloned to a real HDD, etc.)
  3. Is mountable in Windows, so I can include it in my build process
Turns out the best fit is the "Virtual Hard Disk" format. In Windows, it's possible to mount VHD files using the management console. But I don't want to go through all the hassle to mount it with a few mouse clicks, build the kernel, unmount it with more mouse clicks, before I can actually test it.

So I made vhdutil, which is available here: https://github.com/dnifan/vhdutil

After building, you can simply use these commands:

vhdutil.exe attach <file> to mount a VHD file.
vhdutil.exe detach <file> to unmount a VHD file.

It's licensed under the MIT license, so go right ahead and do whatever you want.

Wednesday, April 27, 2016

ttOS R0.2

The first blogpost since a month! And I have a lot to show (I think).

First, a quick round-up of the latest modifications:

  • Added views system
  • Implemented kernel service model
  • Heap locking
  • Safety checks & documentation
  • Added version numbering
Details after the break!

Tuesday, March 22, 2016

Temporarily switching to real mode to use BIOS functions

Well, I finally did it. It took me exactly two days (or 16 hours) to write a piece of code that would allow me to temporarily drop back to real mode, call some BIOS interrupts, and then go back to protected mode again. The fact that I use MSVC++ and the COFF object file format didn't actually help me, as I had to be quite inventive to work around the limitations of the COFF format.

Anyway. I have now used this technique to upgrade my console from 80x25 characters to a whopping 80x50! So one might wonder if this was worth all the time. I guess so, since I can now also switch to graphics mode, and get ACPI information, et cetera.

Look at this huge console! It seems like the VGA cursor suddenly stopped working though. I'm thinking of simply implementing my own using the underscore character, and the PIT timer.


Thursday, March 17, 2016

Syntactic sugar with C++ and more...

So in my previous blogpost I briefly spoke about switching to C++ from pure C. I really like it so far. Since the majority of code I write at work is C#, I've become very accustomed to object oriented thinking.

Currently, the driver model, device model, interrupt handling, terminal, and more have been migrated to C++. Also, I implemented a LinkedList<T> class.