Dusk Examples

This is a collection of examples of Dusk packages, that is, applications written in Dusk's Forth and wrapped through Dusk's Usermode to provide a portable executable that is small and fast.

This code is available from Dusk OS' files folder or as a Git repository (without SSL) at:

git://git.duskos.org/dusk-examples.git

Requirements

Dusk's Usermode runs natively on the host machine, but this means that it can only run on CPU architectures supported by Dusk. See Usermode README for details.

To build this project, you need:

Build

Run make in this project's root directory. This will compile all examples. These executables are standalone.

Frozen!

All examples support freezing. Because it's not all host OSes that can build them, they're not built by default. To freeze an example, use the _frozen target. For example, make hello_frozen will yield a frozen hello example.

Examples description

hello

Invoking ./hello will print "Hello World!" and exit. Invoking it with a single argument will greet that name instead. Other arguments are ignored.

sievec

This is a "Byte Sieve" benchmark as shown on the website's main page and compiled with Dusk CC. You run it with ./sievec without arguments. On most system, you can time it with a command that looks like time ./sievec.

This is a good example of a more complex package because it uses a filesystem to load DuskCC. It embeds a tar of Dusk's files in the executable itself and uses this as a filesystem.

It's also a good example of an API extension: access to the tar data is done through an extra API function.

On top of that, it's a good example how we can be "smart" about freezing: if you look at sievec.c, you'll see that we've carefully #ifdef-ed out the tar embedding from the frozen executable because once frozen, we don't need filesystem access anymore.

sieve

This is a "Byte Sieve" benchmark as shown on the website's main page. You run it with ./sieve without arguments. On most system, you can time it with a command that looks like time ./sieve.

This timing will include "warm up" time, that is, the time Dusk needs to compile itself up, then compile the sieve word.