Musings of a Fondue

Tag: C

Windowing System Tutorial

I plan to have a graphical interface in the homebrew computer. To this end, I am learning about windowing systems.

- Overview -

The main components of a windowing system seem to roughly be:

  • hardware interfacing
    • communicating with input (mouse, keyboard) and output (screen) devices
  • state management
    • tracking the state of a window. For example its position, size, parent, children, visibility
  • rendering
    • determining the most efficient way to draw a window
    • adding window decorations
  • window server and client communication
    • the server notifying clients of events (eg. mouse move, window exposed)
    • clients sending requests to the server (eg. change window title, get contents of clipboard) and receiving responses from the server (eg. contents of clipboard)

- Tutorial -

I came across Joe Marlin’s awesome Windowing Systems By Example tutorial series (archived here). In it, we are shown how to create a simple stacking window manager. It uses clipping regions to draw/update only the visible parts of a window. The series covers the “state management” and “rendering” parts of a windowing system.

Xv6 Mods

Xv6 is a simple operating system (based on Version 6 Unix). It was created as a teaching aid and as such has a relatively small code base. It also comes with a book which explains how its key components work.

The small size and generous documentation (commentary book, lectures) makes it an excellent candidate for my homebrew computer. My goal is to understand the OS completely, so that I can adapt it for use on the computer.

- Applications -

Xv6 is intentionally lightweight. As such it comes with only a few user-space utilities (all command-line based):

  • cat
  • echo
  • grep (minimal)
  • kill (minimal)
  • ln
  • ls (minimal)
  • mkdir
  • rm
  • sh (minimal)
  • wc

This is great for teaching, but poor for usability. To make the OS more useful, I plan to grow the number of user-space utilities.

James Molloy OS Tutorial

I wanted to get my feet wet with regards to writing operating systems from the ground up. I came across this awesome tutorial by James Molloy. In it, he walks through the creation of an ultra minimal unix-like operating system.

— Setup —

Setting up my environment took quite a bit of time. The setup instructions are aimed at a Linux/macOS environment whereas I am running Windows. Luckily, Windows Subsystem for Linux (WSL) is a thing and I was able to continue along. However, there was a catch - WSL does not have a graphical user interface (GUI).1 This meant I could not use Bochs (the emulator used in the setup instructions).2