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:gccon Linux (sudo apt install build-essentialon Debian or Ubuntu); on macOS, the Command Line Tools (xcode-select --install), wheregccis Clang. - Optional: GTK 3, for the graphical programs (
moving_window,color_*,message_viewer):sudo apt install libgtk-3-devon Debian or Ubuntu,brew install gtk+3on macOS. Without it,makeskips 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:
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 themacosx_mqueueemulation of the Interprocess communication chapter.
Run the Rust examples¶
The Rust examples form one Cargo workspace:
Each one corresponds to the C file of the same name.