Linux Systems Programming#

The material below covers “what an old UNIX greybeard knows about his favorite OS”. It is not to be seen as classical slide material, but rather as support material for didactical live programming [2].

It is not meant to be complete, and it never will be. I leave that task to other authorities - Michael Kerrisks site is heavily cited from here; he offers courses at that level.

Note that this is not an agenda for a single course. This material is a set of building blocks, used to compose a course that is adapted to the audience.

Fundamentals#

This section covers the stone-old UNIX concepts [1] that Linux has expanded where necessary (embedded hardware is just a file too). It forms the absolute basis for any kind of serious system level programming.

Event Driven Programming#

../../../../../_images/eventloop-idea.svg

In this section we will develop a semi-realistic application that sits upon a “database”. The application receives input and commands from multiple data sources - and it is single threaded.

Based upon our knowledge of file descriptors (“everything is a file”), we learn how to use advanced I/O multiplexing system calls to dispatch events from multiple sources inside an application that is highly reactive.

Multithreading#

Outdated This is course material which has done its duty already. It is in the queue for refactoring, so it will look like the “regular” material above. It can be booked nonetheless; in this case the booked topics will receive extra priority points for refactoring 😉.

Inter Process Communication#

Outdated This is course material which has done its duty already. It is in the queue for refactoring, to make it look like the “regular” material above. It can be booked nonetheless; in this case the booked topics will receive extra priority points for refactoring 😉.

Scheduling And Realtime#

Outdated This is course material which has done its duty already. It is in the queue for refactoring, to make it look like the “regular” material above. It can be booked nonetheless; in this case the booked topics will receive extra priority points for refactoring 😉.

Graphical Overview#

cluster_sysprog Linux Systems Programming cluster_sysprog_fileio Files And File Descriptors cluster_sysprog_syscalls System Calls cluster_sysprog_eventloop Group sysprog.eventloop cluster_sysprog_process Processes cluster_sysprog_signal Signals sysprog_fileio_create Creating Files sysprog_fileio_dup Duplicating (dup() And Friends) sysprog_fileio_fd File Descriptors: Basics sysprog_fileio_dup->sysprog_fileio_fd sysprog_fileio_output Writing Files sysprog_fileio_open open(): Opening Files sysprog_fileio_input Reading Files sysprog_fileio_lseek File Position/Offset sysprog_fileio_lseek->sysprog_fileio_open sysprog_syscalls_overview System Calls: Overview sysprog_syscalls_errorhandling errno, And Error Handling sysprog_eventloop_poll_cpp A Naive C++ Eventloop (poll()) sysprog_eventloop_poll I/O Multiplexing sysprog_eventloop_poll_cpp->sysprog_eventloop_poll sysprog_eventloop_problem The Problem sysprog_eventloop_poll->sysprog_eventloop_problem sysprog_eventloop_problem->sysprog_fileio_fd sysprog_process_environ Environment Variables sysprog_process_argv Argument Vector (argv) sysprog_process_exit Process Termination: Exit Status sysprog_process_fork Process Creation (fork()) sysprog_process_tree The Process Tree sysprog_process_fork->sysprog_process_tree sysprog_process_unnamed_pipe_ipc Case Study: IPC (Parent/Child) Over Unnamed Pipe sysprog_process_unnamed_pipe_ipc->sysprog_fileio_dup sysprog_process_unnamed_pipe_ipc->sysprog_process_fork sysprog_signal_async_graceful Use Case: Graceful Termination sysprog_signal_async Asynchronous Signal Handling sysprog_signal_async_graceful->sysprog_signal_async sysprog_signal_intro Introduction sysprog_signal_async->sysprog_signal_intro sysprog_signal_async_selfpipe Use Case: Self-Pipe Trick sysprog_signal_async_selfpipe->sysprog_signal_async sysprog_signal_signalfd Event Loop Support: signalfd() sysprog_signal_signalfd->sysprog_fileio_fd sysprog_signal_signalfd->sysprog_signal_intro sysprog_signal_sync Synchronous Signal Handling sysprog_signal_sync->sysprog_signal_intro

Ad-Hoc Live Demos#

Building Blocks For Sketches#

../../../../../_images/building-blocks.svg

Footnotes