💻

OS Development and GitHub Projects

Jul 12, 2024

Lecture on OS Development and GitHub Projects

Introduction

  • Starting the streaming session with audience interaction.
  • Announcement: The first OS development stream, focusing on building lenser OS from scratch.

Initial Setup & Git Cloning

  • Demonstrating various ways to clone a repository, specifically using magit in Emacs.
  • Example URL for cloning lenserOS: github.com/codeberg.org/lensplaysgames/lenseros.git.
  • Discussing pull requests and contributions happening primarily on Codeberg, a non-profit hosting Git repositories.
  • The importance of executable permissions, especially in Linux environments.

Building the Toolchain

  • Toolchain scripts: toolchain.sh orchestrates downloading, patching, and compiling GNU Binutils and GCC.
  • Dependencies required for the script to run, specifically on WSL/Dbian environments.
  • Shell commands to run the script and handle user-specific errors like patch applications.
  • Concurrency and the use of GNU make's -j option to speed up compilations.
  • Known issues like spaces in paths causing script failures.
  • Multiple retries and diagnostics for resolving issues.

Kernel Compilation

  • Usage of CMake for kernel configurations and build options.
  • Important options include MACHINE, HIDE_UART_COLOR_CODES, and QEMU_DEBUG for toggling debug and build specifics.

Creating Boot Media

  • Explanation of GPT, ISO, and RAW targets for creating bootable disk images.
  • Running CMake build commands to create a GPT disk image.

Running the OS in QEMU

  • Running scripts to boot the created OS disk image in QEMU.
  • Success in booting Lenser OS and running basic functionalities like drawing and text input.

Deep Dive: OS Internals

Boot Process

  • UEFI boot loading, parsing/validating kernel, and installing GOP (Graphics Output Protocol).

Memory Management

  • Initializing memory (Memory maps, Identity mapping, and page tables).
  • Physical and virtual memory mapping, Kernel mmap configurations.

CPU and Multithreading

  • Utilization of CPU ID instruction for CPU feature and capability detection.
  • Handling multiple CPUs and logical cores setup.

Peripheral Setup

  • Initialization of peripherals including UART, RTC, and HPET timers.
  • Issues with VirtualBox and specific hardware timers.

File Systems & Partitioning

  • Detection of storage devices and file systems via GPT and FAT drivers.
  • Creation and management of virtual file systems (VFS).

User Space Program Management

  • Handling user space processes: loading, executing, and context switching.
  • Creating standard output (stdout) for user processes.
  • Using syscalls to manage and communicate with user programs.

Debugging and Optimization

  • Insights into avoiding torn reads and ensuring atomic operations.
  • Consideration of process memory handling, scheduling, and deadlock avoidance.
  • Suggestions for external code reviews and contributions, focusing on optimizations and bug fixes.

Tools and Utilities

  • Briefly discussed installing tools like b-top for system monitoring.
  • Comparison between different terminal and shell tools for efficiency.

Closing Notes

  • A reiteration on the contributions via pull requests accepted on GitHub/Codeberg.
  • Encouragement of community interaction through Discord.
  • Mention of plans for further streams and development sessions.