Skip to content

Getting started

What you need

  • A Unix-like system: Linux, macOS, or Windows with WSL (the examples use POSIX system calls, which Windows itself does not provide).
  • A C compiler and make: gcc on Linux (sudo apt install build-essential on Debian or Ubuntu); on macOS, the Command Line Tools (xcode-select --install), where gcc is Clang.
  • Optional: GTK 3, for the graphical programs (moving_window, color_*, message_viewer): sudo apt install libgtk-3-dev on Debian or Ubuntu, brew install gtk+3 on macOS. Without it, make skips them and says so.
  • For the Rust examples: a Rust toolchain (rustup).

Build the C examples

git clone https://github.com/alainlebret/os.git
cd os
make -C exemplier            # every chapter
make -C exemplier/1_process  # one chapter

Each chapter builds its programs in its own bin/ directory. Run them from the chapter directory, since some of them open files given by a relative path:

cd exemplier/1_process
./bin/process_01

make clean removes the object files, make distclean the programs too.

Linux and macOS

Most examples run on both. A few use interfaces that macOS does not provide; they say so in their header and in the README of their chapter (shown at the top of each chapter page):

  • unnamed semaphores (sem_init()): Linux only; use named semaphores (sem_open()) on macOS;
  • POSIX timers (timer_create(), SIGRTMIN): Linux only;
  • POSIX message queues (mq_open()): Linux; on macOS through the macosx_mqueue emulation of the Interprocess communication chapter.

Run the Rust examples

The Rust examples form one Cargo workspace:

cd exemplier-rust
cargo build              # every example
cargo run -p process_05  # one example

Each one corresponds to the C file of the same name.