3.8.2 Creating locks
It is possible for the code in normal context and the code in interrupt context
(i.e. notification functions) to access the same data structure. This is
because UEFI does support a single timer interrupt. This access can cause
issues if the updates to a shared data structure are not atomic. A UEFI
application or UEFI driver that wants to guarantee exclusive access to a shared
data structure can temporarily raise the task priority level to prevent
simultaneous access from both normal context and interrupt context. A lock can
be created by temporarily raising the task priority level to TPL_HIGH_LEVEL
.
This level blocks even the one timer interrupt. However, care must be taken to
minimize the amount of time that the system executes at TPL_HIGH_LEVEL
. All
timer-based events are blocked during this time and any driver requiring
periodic access to a device is prevented from accessing its device. See the
Boot Services chapter of the UEFI Specification for more information on Task
Priority Levels and Section 5.1.4 of this guide for examples on how Task
Priority Levels can be used to create and manage locks.