kernel-test Gets a Desktop (and Multitasking)
Hey everyone,
Last time I said Vexar was going on pause so I could focus on kernel-test, my hobby operating system. Well, here's the first big thing to come out of that: kernel-test can now run several programs at once, on a little desktop of its own.
Here's the tour, plus a small change of plans for the site.
First, a small change of plans
In my last post I said I'd be halting development of Vexar. That's still the plan, but before I go back to my other projects, I'm going to make a few more changes on the security side. No new features and nothing flashy, just some extra work behind the scenes to keep your account and your data safe. Once that's done, it's back to kernel-test.
Before vs. now
Until now, kernel-test could only do one thing at a time: one shell, one screen, one program. If a program got stuck in a loop, so did the whole machine.
Now there's a new desktop command that opens a text-mode desktop, where every terminal, editor and program is its own task, and they all run at the same time. Same OS as before: a 64-bit kernel written in Rust, an 80×25 text screen, no graphics and no mouse (on purpose).
A quick tour

- Type
desktopto open the home screen. It shows the/desktopfolder as a grid of icons, after two built-in ones: Terminal and Files. - Press Enter on an icon to open it. Folders open in the same grid, programs run in a new task, text files open in the text editor and other files in the hex editor.
- Watch the taskbar on the bottom row: Home, every open task, and the date and time.
- Hold Alt and tap Tab to see your tasks, most recent first, then let go of Alt to switch. Alt+H takes you home. (On a serial terminal, Esc then Tab does the same.)
- Use the new commands in a terminal:
startopens a file or a new terminal as a task,taskslists them,killcloses one,exitcloses the one you're in, anddateshows or sets the clock. - Run
clock, a tiny demo program that prints the time every second and keeps going while you work in another task. - Press Ctrl-Q on the home screen to leave. Open tasks get closed (after a quick y/n) and your shell screen comes back exactly as you left it.
The OS still boots straight into the plain shell like before. The desktop is just one command away.
How it works, in three tricks
No need to read this part to enjoy the update, but if you're curious, the whole thing stands on three ideas.
1. Switching tasks means swapping one number
Tasks take turns on the CPU, switched by a timer 100 times a second, so each one gets 10 ms at a time. That's why a program stuck in an endless loop can't freeze the machine anymore.
The fun part: every time an interrupt happens, the kernel already saves all the registers onto the stack. So a paused task is fully described by a single number: the stack pointer where its registers were saved. Switching tasks just means handing back a different one before the registers come back:
call interrupt_dispatch ; rax = stack to resume, rdx = page tables or 0
test rdx, rdx
jz 1f
mov cr3, rdx ; page tables first...
1: mov rsp, rax ; ...then the other task's stack
pop r15 ; ...restore its registers
...
iretq ; and continue where it stopped
Here's that in action: clock kept printing every second in Terminal 1, even while other tasks were in front.

2. Same address, different memory
Every kernel-test program is built to live at the exact same address, 0x4000000. So how do two of them run at once without stepping on each other's toes?
Instead of rewriting the programs, each running program gets its own copy of the page tables, where that same address leads to a different 16 MiB block of RAM. The programs themselves didn't change at all. With 192 MiB of RAM or more, up to 8 programs can run side by side.
The sneaky detail is the order: the kernel has to load the new page tables before the new stack pointer, or it would briefly be looking into the old program's memory. That's what the mov cr3 line above is for.
3. Every task gets its own screen
Before, everything was written straight to the real screen, so there was only ever one. Now each task draws into its own copy of the screen in memory, and only the one in front is shown, on the display and on the serial terminal.
The best part: the editors and programs needed zero changes for this. They keep drawing while hidden, and when you switch back, you see exactly what they did in the meantime. Fun fact: the old keyboard code simply threw Alt away, so "hold Alt, tap Tab" needed Alt support built from scratch.

And a real clock, too
kernel-test now knows the date and time. It reads the PC's battery-backed clock chip, and when you set the time with date -s, it saves only the difference in a small file instead of touching the hardware clock. That way your setting survives restarts (even in QEMU, which resets its clock on every start), and any other OS on the same PC is left alone.
How it was tested
- Every boot now runs 31 self-tests (11 of them new). One makes sure a second task keeps counting while the first one spins forever; another runs two copies of the same program at once and checks that neither overwrote the other.
- Scripts drove the desktop in QEMU: typing commands, pressing Alt+Tab, running two
clockprograms at the same time and checking what ended up on screen. - The serial terminal's output was compared cell by cell with the real screen in 10 different states. They matched every time.
All in all, that's 1,959 lines of new code in 8 new files, changes to 28 others, and two new manual pages.
Good to know
To keep expectations honest:
- One core. Tasks take turns really fast, but nothing actually runs in parallel.
- No protection, on purpose. Everything runs with full access (the user has full control), so a misbehaving program can still take everything else down with it.
- Text mode only. No windows side by side: one task fills the screen at a time.
- Not tried on a real PC yet. All the testing so far ran in QEMU.
Coming to the Alpha branch first
This update is going up on the Alpha branch on GitHub first, instead of going straight to the main one. That gives me time to do some bug fixing before it's considered done. If you want to try it early, that's where to look, just expect a few rough edges.
A quick credit note: I wrote this update myself, with a few small bug fixes from Claude along the way.
Your feedback is still welcome
As always, suggestions, comments and feedback are welcome, whether it's about kernel-test or the site. Leave a comment below or send me a message through Contact.
Thanks for being here 💜
— Vex
Join the conversation
Log in or make an account to comment and vote.
0 comments
No comments yet. Start the conversation.