Skip to content

C programs using POSIX threads to print “What A Wonderful World!” in correct order, demonstrating thread synchronization with semaphores and condition variables (Operating Systems II, UNIWA).

Notifications You must be signed in to change notification settings

Operating-Systems-2-aka-Uniwa/Threads-Synchronization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UNIWA

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

POSIX Threads Synchronization - Semaphores, Condition Variables

Vasileios Evangelos Athanasiou
Student ID: 19390005

GitHub · LinkedIn


Supervision

Supervisor: Vasileios Mamalis, Professor

UNIWA Profile

Co-supervisor: Nikolaos Psarras, Applications Lecturer

UNIWA Profile · LinkedIn


Athens, June 2022



README

POSIX Threads Synchronization - Semaphores, Condition Variables

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!


Table of Contents

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

1. Project Overview

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

2. Objectives

  • Implement multi-threaded execution using POSIX threads.
  • Synchronize thread execution order correctly.
  • Prevent race conditions using mutex protection.
  • Demonstrate synchronization techniques in practice.

3. Key Features

  • 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.


4. Program Structure

  1. Initialize synchronization mechanisms.
  2. Create three worker threads.
  3. Each thread prints its assigned word.
  4. Synchronization ensures proper printing order.
  5. Execution repeats indefinitely.

About

C programs using POSIX threads to print “What A Wonderful World!” in correct order, demonstrating thread synchronization with semaphores and condition variables (Operating Systems II, UNIWA).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages