Csci 474 operating systems concepts project threads and


Operating Systems Concepts Project: Threads and semaphores

I. Project Organization

This project will implement a multi-threaded application using the POSIX threads and semaphores with the programming language of C/C++.  Your program will be tested on a machine (lab00.cs.ndsu.nodak.edu  --  lab20.cs.ndsu.nodak.edu) in the computer science lab QBB 244.

You should do the following pieces to complete your project.  Each piece is explained below:

  • Code
  • Output
  • Summary

Code

Your code should be nicely formatted with plenty of comments.  The code should be easy to read, properly indented, employ good naming standards, good structure, and should correctly implement the design.

Output

Output will be graded by running your program.

Summary: The summary includes the following two pieces.

1. Complete the following table in the summary. In the following table, you should list all semaphores used in the program, the function and initial value for each semaphore.

Semaphore

Function

Initial Value

 

 

 

 

 

 

2. Discuss any difficulties encountered, what was learned, and results. This piece should be at least one page in length (font size - 11 points, single column and single space).

II. Project Description

Data-Center Simulation

You must use POSIX threads and semaphores to complete this project.

This project creates a system to simulate a data center. The following rules apply:

1) 5 data-generator threads are created in the main thread at the start of simulation. Each data-generator thread has a unique index ranging from 1 to 5. Each data-generator thread generates 10 random numbers (no duplicate numbers) with the following requirement:

a) The random numbers generated by data-generator thread 1 are ranging from 100 to 199.

b) The random numbers generated by data-generator thread 2 are ranging from 200 to 299.

c) The random numbers generated by data-generator thread 3 are ranging from 300 to 399.

d) The random numbers generated by data-generator thread 4 are ranging from 400 to 499.

e) The random numbers generated by data-generator thread 5 are ranging from 500 to 599.

2) 2 data-server threads are created in the main thread at the start of simulation. Each data-server thread has a unique index, ranging from 1 to 2.

3) Every number datum has to be processed by a data-server thread. A total of 50 number-data are processed by two data-server threads.

4) If a data-generator thread has unprocessed data, the data-generator thread contacts a data server. A data-generator thread only sends one number datum each time. If data-generator thread i has n unprocessed numbers, data-generator thread i must contact the server thread n times. Each number can processed by the same or different servers. If both data-server threads are busy (i.e., processing data from another data-generator thread), the data-generator thread is waiting for the availability of a data server based on the FIFO order. If both data servers are available, simply choose one server to handle the number datum. Each data-server can only handle one number datum one time.

5) Server Connection. A data-generator thread contacts a data-server thread with the following handshaking procedure:

a) A data-generator thread connects to a data-server thread. (You must print out this activity in the data-generator thread, e.g., Data-generator thread 1 connects to data-server thread 2.)

b) The data-server thread accepts the connection from the data-generator thread. (You must print out this activity in the data-server thread, e.g., Data-server thread 2 accepts the connection from data-generator thread 1.)

c) The data-server thread sends a connection confirmation to the data-generator thread.  (You must print out this activity in the data-server thread, e.g., Data-server thread 2 sends the connection confirmation to data-generator thread 1.)

d) The data-generator thread receives the connection confirmation from the data-server thread. (You must print out this activity in the data-generator thread, e.g., Data-generator thread 1 receives the connection confirmation from data-server thread 2.)

6) A data-server thread sleeps random time (50-200 ms) to simulate the procedure of handling a number datum.

7) Server Completion. A data-server thread contacts a data-generator thread with the following handshaking:

a) The data-server thread sends the completion message to the data-generator thread. (You must print out this activity in the data-server thread, e.g., Data-server thread 2 completes processing number datum 135 and notifies data-generator thread 1.)

b) The data-generator thread receives the notification. (You must print out this activity in the data-generator thread, i.e., Data-generator thread 1 acknowledges the completion of the number datum 135 from data-server thread 2).

8) Repeat the steps 4-7 if any data are not processed. In the server connection (Step 5), you must print out the indices of the data-generator thread and the data-server thread. In the server completion (Step 7), you must print out the number datum in addition to the indices of the data-generator thread and the data-server thread.

9) In the end of the simulation, a report is printed by each data-generator thread. See the following sample. Reports from different data-generator threads should not be interleaving.

Report Of Data-generator Thread 1

135 processed by data-server 2

142 processed by data-server 1

162 processed by data-server 1

115 processed by data-server 2

122 processed by data-server 1

152 processed by data-server 1

112 processed by data-server 1

134 processed by data-server 2

189 processed by data-server 1

184 processed by data-server 1

End of Report of Data-generator Thread 1

Attachment:- Assignment File.rar

Request for Solution File

Ask an Expert for Answer!!
Operating System: Csci 474 operating systems concepts project threads and
Reference No:- TGS02539012

Expected delivery within 24 Hours