Course: Operating Systems Semester: 3rd Main Attributor: Marinos Matthaiou — inf2023004
Three assignments exploring core Unix/Linux operating system concepts in C, developed and tested on Ubuntu 24.04.1.
| # | Topic | Folder |
|---|---|---|
| 2 | File copying via standard I/O vs. low-level system calls (read/write) with custom buffer size |
Ergasia2_mycp/ |
| 3 | Inter-process communication via pipes, fork, and execlp |
Ergasia3_pipe/ |
| 4 | Process synchronization with semaphores and shared memory (mmap) |
Ergasia4_processes/ |
A cp-like utility comparing two copy strategies:
- Standard I/O — byte-by-byte copy using
fgetc/fputc - Low-level system calls —
read/writewith a user-specified buffer size
Execution time for each approach is measured and logged to report.out.
Build & run:
cd Ergasia2_mycp
make
./mycp -b<buffer_size> file1 file2 # custom buffer size via system calls
./mycp file1 file2 # standard I/OFiles:
mycp.c— implementationMakefile— build scriptManual_Ergasia2.pdf— usage manualReport_Ergasia2.pdf— full written reportreport.out— sample timing results from a runtypescript— recorded terminal session demonstrating execution
Uses pipe(), fork(), dup2(), and execlp() to run the Unix cut -c5- command in a child process, redirect its output through a pipe, and read the result in the parent process.
Build & run:
cd Ergasia3_pipe
make
./helper file1Files:
helper.c— implementationMakefile— build scriptManual_Ergasia3.pdf— usage manualReport_Ergasia3.pdf— full written reporttypescript— recorded terminal session demonstrating execution
Spawns 4 child processes (P1–P4) that take turns printing characters (A–D) in a coordinated cyclic pattern, synchronized via a named semaphore and a shared memory segment (mmap). Output is written both to the console and to output.txt. Signal handlers (SIGINT/SIGTERM) ensure proper cleanup of the semaphore and shared memory on exit.
Build & run:
cd Ergasia4_processes
make
./process
# Press Ctrl+C to stop — the process runs in an infinite loop by designFiles:
process.c— implementationMakefile— build scriptManual_Ergasia4.pdf— usage manualReport_Ergasia4.pdf— full written reportoutput_sample.txt— truncated sample of the output (the full run is unbounded)
- C (POSIX APIs:
pipe,fork,exec,mmap,semaphore.h) - GNU Make
- Developed and tested on Ubuntu 24.04.1, gcc