Skip to content

fardinanam/CSE314-pthread-synchronization-offline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSE314 Operating Systems (Offline 4)

Problem Statement

Solution to Part A : Master-Worker Thread Pool

The solution code is in master-worker.c

To run the code, use the following command:

gcc master-worker.c -o master-worker.o -lpthread
./master-worker.o <number-of-items> <max-buffer-size> <number-of-worker> <number-of-producer>

Solution to Part B : Reader-Writer Problem

To test the code, use test-reader-pref.cpp.

To compile and run the code, use the following commands:

    g++ rwlock-reader-pref.cpp -o rwlock-reader-pref.o -lpthread
    ./rwlock-reader-pref.o <number-of-readers> <number-of-writers>

To test the code, use test-writer-pref.cpp

To compile and run the code, use the following commands:

    g++ rwlock-writer-pref.cpp -o rwlock-writer-pref.o -lpthread
    ./rwlock-writer-pref.o <number-of-readers> <number-of-writers>

Solution to Part C : Zemaphore

To test the code, use test-zem.c.

To compile and run the code, use the following commands:

    gcc zemaphore.c test-zem.c -o test-zem.o -lpthread
    ./test-zem.o

Solution to Part D : Server-Client-Database

Problem Statement:

There are multiple databases and one server. More than one client can connect to the server at a time and can request access to a database. The request will only be granted by the server if there is no other client accessing the requested database.

Solutions:

    g++ cv-server-client-database.cpp -o cv-server-client-database.out -lpthread
    ./cv-server-client-database.out
    g++ zemaphore.c zema-server-client-database.cpp -o zema-server-client-database.out -lpthread
    ./zema-server-client-database.out