CS 311 – Operating Systems

One of my required classes this semester was CS 311: Operating Systems. Binghamton University replaced CS 350 with CS 311 this semester – its identical except without the required Lab time; rather, we’re required to complete all of the labs on our own time.

The first lab required us to read from a text file, and create an identical copy of it. There were two versions – one that read/wrote character by character, and one that read/wrote line by line. In either version, the original file was read, then the text was written to the output file. Both CPU Time and Wall Time were calculated to check how the scheduler differed between Windows and Redhat Linux.
Code:
Lab1_Character.c
Lab1_Line.c
Write-Up:
ReadMe.txt

Lab 2 required us to perform matrix multiplication concurrently using threads. The matrices were read in from a single file, with the two matrices being divided by a line of stars ['*'], and stored in a vector-of-vectors [vector< vector >] using the STL vector library in C++. Once the matrices were in memory, the total number of threads were calculated [Number of Rows in M1 * Number of Columns in M2 * Number of Elements per Row of M1], the MatrixMult() function was executed. This function created the threads, and passed the appropriate parameters [M1 Row Index, M2 Column Index, Element Index] for each multiplication to the thread worker function. Mutexes were used to ensure mutual exclusivity while the cross product of each element for the final matrix was determined. I also decided to check out how my Python skills were holding up, and coded Lab 2 in Python as well.
Design Document:
Lab2_DesignDocument.docx
Code:
Lab2.cpp
Lab2.py
Write-Up:
README
Sample Output File:
Output

In Lab 3, we revisited the old Readers/Writers concurrency problem. Rather than using semaphores, as most solutions for this problem do, we were required to use a monitor to provide the synchronization to the threads. The user supplied the program with the necessary parameters via the command, and then was given the option of 3 different modes of operation – 1) Readers have absolute priority, 2) Writers have absolute priority, and 3) the threads are treated on a First Come, First Served basis. For each mode, different logic was used within the monitor to enforce the appropriate conditions for the threads. Every time a Writer was executed, a Database string was updated with the current time of day in the format HH:MM:SS:mmm. Every time a Reader was executed, the Database was read. Each thread wrote a line to an output text file when it executed, allowing the user to see the order in which the threads were run.
Design Document:
Lab3_DesignDocument.docx
Code:
Lab3.cpp
Monitor.h
Monitor.cpp
Makefile
Write-Up:
README
Sample Output File:
Output

These are just the first three labs that were coded for this class; please check back as the class continues and I update with the remainder of the labs we code.

This entry was written by Marc Budofsky , posted on Sunday October 31 2010at 11:10 am , filed under Binghamton University, C/C++, Programming, Python and tagged , , , , , , . Bookmark the permalink . Post a comment below or leave a trackback: Trackback URL.

2 Responses to “CS 311 – Operating Systems”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>