Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be done in C. NAME timer counts down to zero from a user supplied number. DESCRIPTION Displays a count down to zero from a

Must be done in C.

NAME

timer counts down to zero from a user supplied number.

DESCRIPTION

Displays a count down to zero from a number supplied by the user at the command line. Supports pausing and unpausing the countdown. Countdown is done by ones, one second at a time. While the program is runnng, typing p will pause the countdown and typing u will unpause it. echoing of characters is disabled while the program is running.

SAMPLE USAGE

timer 60 begins the countdown

HINTS

o man 3 sleep

o uses struct termios

o uses VSTART and VSTOP

o the terminal driver handles the p/u. The program itself never sees p/u.

SAMPLE OUTPUT

At 57 seconds left, I hit p:

--------------------------------------------------

[123456@chegg ~]$ ./timer 60

60

59

58

57

--------------------------------------------------

This paused the countdown output. Then I hit u to resume the countdown:

--------------------------------------------------

[123456@chegg ~]$ ./timer 60

60

59

58

57

56

55

54

53

52

51

50

--------------------------------------------------

Notice: in neither screen shot do you see the character "p" or the character "u". That's because echo is turned off for the duration of the program.

Once you hit p to unpause, you may see a spurt of output. This is because you're pausing the flow of output from the terminal driver, not the process itself. The process keeps right on writing to the output buffer as usual. Once you unpause, then the output gets written to the screen.

Think of your process as a faucet. Think of the terminal driver as a hose hooked up to the faucet. When you kink the hose, the water stops coming out of the hose, but the faucet is still turned on, pushing water into the hose. As soon as you unkink the house, the water all shoots out at once.

I should point out, depending on which distribution you're working with, you may not see this spurting behavior. The terminal driver may also keep track of the "pauses" caused by sleep and so you'll see the behavior you were expecting.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

10. What is meant by a feed rate?

Answered: 1 week ago

Question

=+5 Does this case provide an example of the future for IHRM?

Answered: 1 week ago