Specifications

CHAPTER 6. REQUIREMENTS VERIFICATION 58
Figure 6.1 gives an overview of the time needed by an input event to reach a user space
application. The user action on an input device triggers a hardware event which attains kernel
space—the input device’s driver—either by generating an interrupt or by being polled. This
period of time is denoted as t
1
. The time interval between the reception of the input event by
the input device’s driver, and the actual receiving by an application in user space, is denoted
as t
2
. Thus, the time t
total
an input event needs to reach a user space application equals to:
t
total
= t
1
+ t
2
Hardware
Kernel Space
User Space
Software
Input Device Device Driver User Space Interface Application
t
1
t
2
t
total
Input Abstraction Layer
Figure 6.1: Time Interval for Input Events to Reach User Space
The time interval t
1
heavily depends on the kind of the input device. An input event of
an interrupt-driven input device has a t
1
less than an input event of a polled input device. In
general, t
1
for interrupt-driven devices can be neglected. It is of the order of magnitude of one
millisecond. The time interval t
1
of a polled input device depends on how often the polling is
executed. Hence, for polling devices, no general predication for the actual value for t
1
can be
made.
The second time interval t
2
is determined the kernel driver iallatency. The first measuring
point is set in kernel space at the time the driver of an input device gets notice of the occurrence
of an input event. The second measuring point is invoked by a user space application right
after receiving the input event. At both measuring points, the current value of jiffies is
stored. Thus, the measurement of t
2
is accurate with a one millisecond tolerance. Beside the
implementation of the kernel driver, several parts of the kernel itself had to be modified to
accomplish the measurement:
Definition of a global variable used to store the first measuring point
Modification of the input device drivers to store the first measuring point
The global variable was added to init/main.c of the kernel source code. The following
source code shows the additional code:
unsigned long event_jiffies = 0;
EXPORT_SYMBOL(event_jiffies);