React – trial runs

It is best to see the program in action; of course, the reader would do well (and enjoy this exercise a whole lot more!) to actually build and try it out for himself/herself:

$ ./react 
Usage: ./react <freq-in-millisec> [verbose-mode:[0]|1]
default: verbosity is off
f.e.: ./react 100 => timeout every 100 ms, verbosity Off
: ./react 5 1 => timeout every 5 ms, verbosity On

How fast can you react!?
Once you run this app with the freq-in-millisec parameter,
we shall start a timer anywhere between 1 and 5 seconds of
your starting it. Watch the screen carefully; the moment
the message "QUICK! Press ^C" appears, press ^C (Ctrl+c simultaneously)!
Your reaction time is displayed... Have fun!

$

We first run it with a 10 millisecond frequency and without verbosity:

$ ./react 10
Initializing timer to generate SIGRTMIN every 10 ms
[Verbose: N]
We shall start a timer anytime between 1 and 5 seconds from now...

GET READY ...
[ when the "QUICK! Press ^C" message appears, press ^C quickly as you can ]

After a random interval of between 1 and 5 seconds, this message appears and the user must react:

*** QUICK! Press ^C !!! ***
^C
*** PRESSED ***
Your reaction time is precisely 0.404794198 s.ns [~= 405 ms, count=40]
$

Next, with a 10 millisecond frequency and verbose mode on:

$ ./react 10 1
Initializing timer to generate SIGRTMIN every 10 ms
timer struct ::
it_value.tv_sec = 0 it_value.tv_nsec = 10000000
it_interval.tv_sec = 0 it_interval.tv_nsec = 10000000
[SigBlk: -none-]
[Verbose: Y]
We shall start a timer anytime between 1 and 5 seconds from now...

GET READY ...
[ when the "QUICK! Press ^C" message appears, press ^C quickly as you can ]

After a random interval of between 1 and 5 seconds, this message appears and the user must react:

react.c:arm_timer:161: Arming timer now

*** QUICK! Press ^C !!! *

Now the period character,.,appears rapidly, appearing once for every single expiry of our POSIX interval timer; that is, once every 10 ms in this run.

.....................................^C
*** PRESSED ***
Your reaction time is precisely 0.379339662 s.ns [~= 379 ms, count=37]
$

In our previous sample runs, the user took 405 ms and 379 ms to react; as we mentioned, it's in the hundreds of milliseconds range. Take the challenge—how much better can you do?

Research findings indicate the following numbers for average human reaction times:

Stimulus Visual Auditory Touch
Average human reaction time 250 ms 170 ms 150 ms

Source: https://backyardbrains.com/experiments/reactiontime.

We have become used to using phrases such as "in the blink of an eye" to mean really quickly. Interestingly, how long does it actually take to blink an eye? Research indicates that it takes an average of 300 to 400 ms!
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset