Chat with us, powered by LiveChat Instructions:?? Can be implemented in C or C++ Thread 1: The player thread While playing, the player thread reads one word from the file, prints it, then sleeps until the next word | Wridemy

Instructions:?? Can be implemented in C or C++ Thread 1: The player thread While playing, the player thread reads one word from the file, prints it, then sleeps until the next word

  

Can be implemented in C or C++

Thread 1: The player thread

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 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.

The control threads

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. 

    Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

    Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

    Do you need an answer to this or any other questions?

    About Wridemy

    We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

    How It Works

    To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

    Are there Discounts?

    All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

    Hire a tutor today CLICK HERE to make your first order

    Related Tags

    Academic APA Writing College Course Discussion Management English Finance General Graduate History Information Justify Literature MLA