UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS
University of West Attica · Department of Computer Engineering and Informatics
Operating Systems II
Vasileios Evangelos Athanasiou
Student ID: 19390005
Supervision
Supervisor: Vasileios Mamalis, Professor
Co-supervisor: Nikolaos Psarras, Applications Lecturer
Athens, June 2022
This repository contains an assignment for Operating Systems II, focusing on thread synchronization using POSIX threads to repeatedly print the phrase:
What A Wonderful World!
| Section | Folder/File | Description |
|---|---|---|
| 1 | assign/ |
Assignment material |
| 1.1 | assign/ASK-2B-OS-II-LAB-2021-22.png |
Assignment description in English |
| 1.2 | assign/ΑΣΚ-2Β-ΛΣ-ΙΙ-ΕΡΓ-2021-22.png |
Assignment description in Greek |
| 2 | src/ |
Source code implementations |
| 2.1 | src/semaphores.c |
Semaphore-based synchronization |
| 2.2 | src/condition_vars.c |
Condition variable synchronization |
| 3 | README.md |
Project documentation |
| 4 | INSTALL.md |
Usage instructions |
The project demonstrates synchronization techniques using POSIX threads to ensure correct printing order among multiple threads.
Three threads cooperate:
- Thread 1 prints
"What A " - Thread 2 prints
"Wonderful " - Thread 3 prints
"World!"
The program continuously prints the phrase in correct sequence.
Two synchronization approaches are implemented:
- Semaphore-based synchronization
- Condition variable synchronization
- Implement multi-threaded execution using POSIX threads.
- Synchronize thread execution order correctly.
- Prevent race conditions using mutex protection.
- Demonstrate synchronization techniques in practice.
-
Thread Cooperation
Multiple threads cooperate to print a single output sequence. -
Synchronization Control
Ensures proper execution order. -
Mutex Protection
Prevents race conditions in shared resources. -
Continuous Execution
Program runs until manually terminated.
- Initialize synchronization mechanisms.
- Create three worker threads.
- Each thread prints its assigned word.
- Synchronization ensures proper printing order.
- Execution repeats indefinitely.
