Operációs rendszerek
Operating Systems
In the practical sessions we write C programs that talk to the operating system directly: they create processes, send each other signals and exchange data through pipes, message queues and shared memory.
Every session explains the system calls with diagrams of what happens between the processes, and shows the few lines that matter. The last part of the semester puts everything together in tasks where a given situation has to be simulated.
Requirements
What it takes to complete the practice part. Dates and deadlines are on Canvas.
Assignments
Two take-home assignments that build on each other
The second assignment continues and extends the first one.
Theory test
15 questions in 15 minutes, on Canvas
8 correct answers pass. 0–7: fail (1) · 8–9: pass (2) · 10–11: satisfactory (3) · 12–13: good (4) · 14–15: excellent (5)
Practical test
A 90-minute programming task, submitted on Canvas
The basic task is worth a pass (2); every further task block that is correct and complete adds one grade.
Course server
ssh <neptun-code>@opsys.inf.elte.hu
Your Neptun code in lowercase, with your faculty (IIG) password. Compile and test your programs there – see the guide below.
Sessions
Open a session here, or on its own page in a new tab.
Session 1
C basics: pointers, strings and files
The C under everything else: argc/argv, pointers, strings that end in a 0 byte, and the two ways to a file – buffered fopen/fgets and raw open/read/write – with the loop conditions that keep them correct.
Session 2
fork() copies the calling process and returns twice. What the child inherits, why variables are not shared, how several forks form a tree, why output can appear twice, and what zombies and orphans are.
Session 3
exec, system and waiting for children
waitpid and the status macros, exec that puts a new program into the same process, the fork + exec + wait pattern every shell uses, what survives exec, and system() as the shortcut through /bin/sh.
Session 4
What a signal is and where it comes from, handlers with sigaction and what is safe inside them, blocking and sigsuspend instead of a racy pause, the parent–child “ready” handshake, and reaping children with waitpid, WNOHANG and SIGCHLD.
Session 5
Pipes, named pipes and message queues
Moving data between processes: pipes and why every process closes the ends it does not use, sending ints, strings and structs with the right sizes, named pipes with mkfifo, and System V message queues with typed messages.
Guides
Stand-alone pages: references, background reading and fixes for common problems.
Guide
Compiling and running C on the course server
Logging in with ssh and copying with scp, gcc with -o, -Wall, -Wextra and -Werror, reading a compiler message, choosing between man 2 and man 3, and cleaning up the stray processes and IPC objects a broken run leaves behind.
Guide
Records in a file: a CRUD skeleton for the assignment
How a record keeper over a text file is built: a struct and its TAB-separated line, reading records with fscanf, unique ids, line-based input that cannot overflow, and modify and delete through a temporary file and rename – the base of the first take-home assignment.
Practice
Simulation tasks: everything together
Four practice tasks in the style of the practical test – a vaccination day, a thesis registration, a press conference and a masked quiz – each a story whose characters are processes that signal, talk through pipes and message queues and share memory under a semaphore.