Operating Systems, CSCE 4413

Homework Assignment 3

As before, this assignment is to be done on your own, and with the help of the textbook or other legitimate resources.

Part 1: Written Exercises

Write the answers to these in plain text and submit the file to the Homework Submission Page.

  1. Suppose that in a real-time system that P1 has a computation requirement of 1 second with a period of 6 seconds, P2 has a computation requirement of 1 second with a period of 4 seconds, and P3 has a computation requirement of 1 second with a period of 3 seconds.
    1. Does the Rate Monotonic Scheduling Algorithm guarantee that a feasible schedule can be built? Show your calculations.
    2. Use the RMS algorithm to develop a real-time schedule for processes P1, P2, and P3.
    3. What is the processor utilization for your scheduled system?

  2. From the text, do exercises 7.1, 7.2, 7.4, 7.7, and 7.18.

Part 2: Programming Exercise

The goal of this assignment is to write a program in which multiple threads write to a common shared resource. You may think of your threads as processing values that are being read from several real-time sensors.

You will need to do this exercise in Linux. You may use either C or C++ and the pthreads library, or you may do your assignment in Java. If you do your assignment in Java, you may need to look up some background material on your own.

To Prepare:

Overview:

Your program will create up to four threads. Each thread is responsible for calculating a sum of integer values from a distinct disk file. You can think of each value in the file as a value returned from a real-time sensor. Each thread should access its own disk file which is separate from the files accessed by other threads.

The running total should be maintained in memory that is shared between the threads. Access to the total should be synchronized with a mutual exclusion lock. Once EOF is reached, each thread should output its subtotal and count of lines read. The main thread should output the final total at the end.

Specifications:

Write a C or C++ program using the pthread library that consists of code for main, a user thread, and supporting functions as needed. The code for main must do the following:

The code for sensor thread must do the following: As always, ensure that you use good programming practice (e.g., put in a sufficient number of comments to explain what your program does, use good formatting, and so on).

Submit: Your source file and Makefile to the homework submission page. Be sure that your source file compiles and executes on Linux.

Enjoy!


Send comments or suggestions to aapon@uark.edu