Modify HW05 to use signals to pause the output of the timer

Modify HW05 to use signals to pause the output of the timer instead of control characters. So, the only terminal setting you will need to modify programatically is echoing. If the user hits ctrl-C, the program pauses. If they hit it again, it unpauses. Ctrl-\\ terminates and restores the settings gracefully.

Hints :

Spinlocks :

while( pause == true)
{}

If pause is set to true, then this while loop will iterate. When pause gets set to false, this loop gets skipped.

See the attached code for a spinlock example, spinlock.cpp

Spinlock.cpp

HW5

Solution

reset game;

roll two dice and sum;

increment number of rolls;

point = sum;

if (point was a 7 or 11)

game is won;

else if (point is not 2, not 3 and not 12) {

do {

roll two dice and sum;

increment number of rolls;

value = sum;

} while (value is not point or is 7);

if (value is point)

   game is won;

else

      game is lost;

}

Modify HW05 to use signals to pause the output of the timer instead of control characters. So, the only terminal setting you will need to modify programatically

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site