Skip to content

matthaioum/Operating-Systems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Operating Systems — Assignments 2–4

Course: Operating Systems Semester: 3rd Main Attributor: Marinos Matthaiou — inf2023004

Overview

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/

Assignment 2 — mycp: Custom File Copy Utility

A cp-like utility comparing two copy strategies:

  • Standard I/O — byte-by-byte copy using fgetc/fputc
  • Low-level system callsread/write with 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/O

Files:

  • mycp.c — implementation
  • Makefile — build script
  • Manual_Ergasia2.pdf — usage manual
  • Report_Ergasia2.pdf — full written report
  • report.out — sample timing results from a run
  • typescript — recorded terminal session demonstrating execution

Assignment 3 — Pipe-based Inter-Process Communication

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 file1

Files:

  • helper.c — implementation
  • Makefile — build script
  • Manual_Ergasia3.pdf — usage manual
  • Report_Ergasia3.pdf — full written report
  • typescript — recorded terminal session demonstrating execution

Assignment 4 — Synchronized Multi-Process Printing

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 design

Files:

  • process.c — implementation
  • Makefile — build script
  • Manual_Ergasia4.pdf — usage manual
  • Report_Ergasia4.pdf — full written report
  • output_sample.txt — truncated sample of the output (the full run is unbounded)

Tools / Language

  • C (POSIX APIs: pipe, fork, exec, mmap, semaphore.h)
  • GNU Make
  • Developed and tested on Ubuntu 24.04.1, gcc

About

C implementations for Operating Systems coursework - custom file copy utility, pipe-based IPC, and semaphore-synchronized multi-process printing, tested on Ubuntu.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors