Project 1 for CSCE4600
Go to file
2022-05-05 06:16:11 +00:00
inc +Attribution 2022-04-06 01:45:57 -05:00
src +Attribution 2022-04-06 01:45:57 -05:00
.gitignore Update Makefile to produce dependencies & objects 2022-04-05 17:56:11 -05:00
LICENSE Update 'LICENSE' 2022-05-05 06:15:52 +00:00
Makefile +Attribution 2022-04-06 01:45:57 -05:00
pseudocode.txt ++Attribution 2022-04-06 01:47:29 -05:00
README.md Update 'README.md' 2022-05-05 06:16:11 +00:00

4600-project-1

Project 1 for 4600
I got a grade of 101.5% :D

Please ensure you've read and agree to abide by the license before continuing.
This software's source code was made public under a restrictive license with the intent to allow comparison of Project 1 solutions with other former course-members and members of the general public. I'm not liable for any academic stupidity that may result from attempted plagiarism of this work.

You have been warned.

Build

Build with make

Run with make run

Clean with make clean

Explanation of Solution

Counting Semaphores:

This project uses four counting semaphores:

  • sem_freelist tracks the number of blocks on the freelist.

    • This prevents any thread from trying to read a nonexistent (nullptr) block from the freelist.
  • sem_freelist_minus_1 tracks the number of blocks on the freelist minus 1:

    • This is used to circumvent a deadlock situation where Thread-1 (the producer) will eat the last block on the freelist and put it on list1, where Thread-2 (the transformer) will never be able to consume it, since it's blocked on the empty freelist.
    • Without this, you'd need to check that sem_freelist > 1, and the project specifications only allow the use of P() and V(), A.K.A. wait() and signal().
  • sem_list1 tracks the number of blocks on list1.

    • This prevents any thread from trying to read a nonexistent (nullptr) block from list1.
  • sem_list2 tracks the number of blocks on list2.

    • This prevents any thread from trying to read a nonexistent (nullptr) block from list2.

All counting semaphores were used for thread synchronization.

Binary Semaphores:

This project uses three binary semaphores:

  • sem_freelist guarantees mutual exclusion when accessing the freelist.

    • This prevents memory corruption, as list accesses are thread-unsafe.
  • sem_list1 guarantees mutual exclusion when accessing list1.

    • This prevents memory corruption, as list accesses are thread-unsafe.
  • sem_list2 guarantees mutual exclusion when accessing list2.

    • This prevents memory corruption, as list accesses are thread-unsafe.

All binary semaphores were used for mutual exclusion.