Project #8: Semaphores

Submit: Your code will be accessible for grading and TA-Bot runs if it is placed in a properly named project_8 branch.

Work should be completed in pairs. Be certain to include both names in the comment block at the top of all submitted source code files. It would be courteous to confirm with your partner when submitting the assignment. You may modify any files in the operating system, but only changes to dispatch.c and testcases.c will be graded for this assignment.

Preparation

First, copy your project_6 branch into a new project_8 branch:
    git switch project_6
    git branch project_8
    git switch project_8
Now this is the important one folks
    git push -u origin project_8
Then, on your project_8 branch (you should already be here), untar the new project files on top of it:
    tar xvzf ~brylow/os/Projects/xinu-hw8.tgz
Commit and push your changes to GitHub:
    git add .
    git commit -m "<message>"
    git push

New files:

system/semcreate.c   Allocates a semaphore slot and initializes its count.
system/semfree.c   Frees a semaphore, wakes any waiting processes, and marks the semaphore slot as free.
system/signal.c   Increments the semaphore's value and signals that a resource is now available.
system/wait.c   Decrements the semaphore's value and blocks the calling process until the resource becomes available.
system/sleep.c   Clock based millisecond sleep function using delta queues. Wakes sleeping processes when their delay expires.
include/semaphore.h   Declares semaphore types, constants, and the semtab entries.

Notable Additions:

PRWAIT   The process state indicating that a process is blocked while waiting on a resource - semaphore. It cannot run until it's condition is satisfied.
PRSLEEP   The process state indicating the process is temporarily inactive (sleeping) for a specified time and will be moved back to ready when it wakes up.
semtab   Similarly to proctab, this is where semaphores will be stored.

Project Goals

This week, you will implement semaphore synchronization and use it to solve a classic concurrency problem. You will implement signal, wait(), sleep(), and wake(). You will need to write both the actual function implementation, as well as their perspective system calls. In addition to signal, wait, sleep, and wake you are tasked with building a testcase that shows the producer and consumer problem as seen in Midterm #2 - using semaphores.

It's important to note that when calling the functions you are tasked with building, you must call the user wrapper, rather than the function itself. Your solution should show waking.

 

Testing

As said before, it is required that you show producers and consumers running concurrently. Additionally, the rest of your test cases should show correct synchronization and no race conditions. Be sure to remove any print-debug statements befor submitting.


[back]

[Revised 2023 Feb 22 02:42 DWB]