Search

Custom Search

Thursday, November 25, 2010

computer science assignment

Operating Systems Concepts
CSci 474
Project #2: Threads and semaphores
Due Date: 11:55PM, December 1, 2010
I. Project Organization
This project will study multiple thread programming, using semaphores and POSIX.
You should do the following pieces to complete your project. Each piece is explained below:
• Design 10 points
• Code 25 points
• Output 10 points
• Summary 5 points
Design
List each semaphore with its purpose and initial value. Provide pseudocode for each thread.
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 on the UNIX machines in Lab 244.
Summary
The summary section should discuss your simulation, any difficulties encountered, what was learned,
and results. It should be at least one page.
II. Project Description
You must complete this project based on POSIX.
This project simulates a game through multithreading. The following rules apply:
1. The main thread creates a server thread and two player threads.
2. A player thread is blocked until a server thread is created - the player thread cannot join a game
until the server thread is created.
3. Each game must have exactly two players -- the server thread cannot start the game until two
players join the game.
4. After the game starts, each player thread randomly generates an integer and passes this integer to
the server thread.
5. The server is waiting for randomly generated integers from two players.
6. The player threads wait for the result from the server.
7. The server thread compares integers and notifies two player threads the result (the thread which
generates a larger integer wins). Game ends.
Your output must show all activities in each thread.
For example:
Main thread creates the server thread.
Main thread creates the player thread 1.
Main thread creates the player thread 2.
Server threat starts.
Player thread 2 starts.
Player thread 1 starts.
Player thread 1 joins the game.
Player thread 2 joins the game.
Server thread starts the game.
Player thread 2 passes 123 to the server.
Player thread 1 passes 234 to the server.
Server announces player 1 wins the game.
GAME OVER.
III. Project Guidelines
Submitting
Submit your project on Blackboard. Include in your submission the following files:
1) A Word document for the written pieces of the project
2) Your source files
NO hardcopy submission. Late submission will NOT be accepted.
Cheating
All work must be your own. If cheating is detected, all parties involved will be given a zero for the project
and the penalty will be documented on a form that you must sign. You may be referred to the Dean's
office for further discussion.
Grading
The written portions will be graded subjectively based on completeness and quality. The code will be
graded based on points allocated for each key part of the processing as determined by the instructor. The
output will be graded based on expected results for the runs.

No comments:

Post a Comment