Google Answers Logo
View Question
 
Q: CS4560-Operating System ( No Answer,   1 Comment )
Question  
Subject: CS4560-Operating System
Category: Computers > Operating Systems
Asked by: enm-ga
List Price: $10.00
Posted: 12 Jun 2003 03:36 PDT
Expires: 12 Jul 2003 03:36 PDT
Question ID: 216382
Write a C or C++ program using POSIX threads and mutexes and condition
variables , which implements a solution to the Media Playback Control
Problem (described below) that is free from deadlock.

The Media Playback Control Problem
Consider a system with three control threads and one player thread.
The player thread plays back a media stream, consisting of some
digital medium such as digital audio or video (or, in our case, text).
The player has two modes: playing, and stopped. The player thread
maintains a current media position, which changes periodically when
the player is playing, and can be affected by commands such as
Rewind(). The player accepts the following commands:
LoadFile(const char *filename) -- Prepares the player to playback the
file whose name is passed in. Stops the player if currently playing.
Stop() -- Stops the player if currently playing. 
Start() -- Starts the player if currently stopped. 
Rewind() -- Sets the position of the player to time 0. 
SeekTo(int byteoffset) -- Sets the position of the player to the
closest word boundary past the given byte offset from the start of the
file.
SetRate(float rate) -- Sets the playback rate: 1.0 is forward at
normal speed, -1.0 is reverse, 0.5 is forward at 1/2 speed, etc.
While playing, the player thread reads one word from the file, prints
it, then sleeps until the next word should be displayed, and so on.
Each word should be displayed on a separate line of output. (Words are
white-space-separated runs of characters.) At a rate of 1.0, the
player should print one word per second. At a rate of -1.0, the player
prints one word per second, but proceeding backwards through the file.

For this assignment, the player plays back text files, displaying one
word per second at normal rate (1.0).

The control threads generate commands for the player thread. You can
think of each control thread as corresponding to a separate remote
control. There are two kinds of control threads. The first kind waits
for keypresses, and issues commands to the player thread based on the
key pressed:

' ' (blank) -- toggles the player's mode between 'playing' and
'stopped'
'r' -- rewinds the player 
's' -- prompts the user for a time, then seeks the player to that time
'l' -- prompts the user for a file, then loads the file into the
player
't' -- prompts the user for a rate, then uses it to set the player's
rate
Two other control thread are "autonomous" controllers, simulating
another user issuing commands. One of the autonomous controllers
periodically issues a Stop() command to the player, while the other
autonomous controller thread issues a Start() command every so often.
Each of these autonomous threads should sleep for a random time
interval of between 5 and 30 seconds before issuing each command.

Your program should implement a function for each command (Start(),
Stop(), etc.). These functions will be called by the control threads
to control the player. Shared, global variables for the state, rate,
position, etc. of the player thread are accessed by these routines, as
well as the player thread routine. You must sychronize access to these
variables to prevent race conditions, using mutexes (and optionally
condition variables).

You program should first initalize the shared variables, then start
the player thread (in "stopped" mode), then the control threads. The
"keyboard" control thread should also have a command that will cleanly
terminate all of the threads and exit the program.

You must also demo your project to the instructor or grader, either in
class, during office hours or other appointed time.
Answer  
There is no answer at this time.

Comments  
Subject: Re: CS4560-Operating System
From: politicalguru-ga on 13 Jun 2003 08:25 PDT
 
Dear ENM, 

As I wrote in another comment, I doubt it if some of our computer
experts would invest much time in a question that is priced at $2. You
may want to reconsider your pricing.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy