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


I implemented multitasking this weekend. It's a cooperative, object-oriented model which uses hardware multitasking. An abstract class Task exists, which can be inherited. The Task contains various attributes that are important to the scheduler (see next section) for correct operation. Also, it contains a protected method Yield which will yield control to the scheduler.

The virtual Run method has to be implemented in the inheriting class. This method contains the code that has to be run inside the multitasking environment.

Multitasking requires a scheduler. Whether it's a simple round-robin one, or something priority-based, a scheduler is necessary to distribute the processor time. I am very intrigued by the so-called lottery scheduler. Like it explains in the link, it allows for a sophisticated priority system: if it requires more priority, just give it more tickets! Also, I'm simply fascinated by the concept :). So yep, that's what the Tickets attribute is in the class diagram above!

In this screenshot, you can see two separate tasks outputting either X or O to a view. As is normal in a multitasking system, it is not a consecutive string of alternating Xs and Os, but you can see the effect of the scheduler quite well.


Until now, I had a "debug view" to which I simply dumped all kinds of system logging. I felt that it was time to organize this a little bit more. I've been toying with the idea of routing log messages over the serial port, so the logging system needed an overhaul anyway.

I introduced logging levels (debug, info, warning, error) and a timestamp. The different logging levels are also printed in a different color, so bad things are now visible quite immediately. As seen in the screenshot below, the debug view has also been renamed to "log".

The next step would be to write some kind of "channel system", so I can also output the log to the serial port.

BASIC interpreter

As a little gimmick to show off the (multi)tasking system, I implemented the very tiny uBASIC interpreter as a Task.

With a few minor improvements to the View code, it's now possible to run a simple BASIC script, as demonstrated in the YouTube video below:

Show Comments