[if !mso]> [if !mso]>

RE: [EDK DEV] Questions regarding TPL

Subject: RE: [EDK DEV] Questions regarding TPL

From: Hot Tian <hot.tian@intel.com>

To: dev@edk.tianocore.org

Date: 2008-10-14 17:07:23



From: Tian, Feng
Sent: 2008
1012 12:26
To: dev@edk.tianocore.org
Subject: RE: [EDK DEV] Questions regarding TPL



Let me try to interpret TPL concept and usage.


EDK is a typical firmware infrastructure. An important difference between firmware infrastructure and OS is EDK has not task schedule mechanism and whole control flow is executed sequentially. However, there has been such a demand that some functionalities need to be called asynchronously or synchronously.  For synchronous execution demands, EDK uses H/W interrupt to handle them (note that currently we only use timer interrupt, and it actually is used to handle EFI_TIMER event). For asynchronous demands, EDK uses TPL which is actually a callback mechanism. When TPL is restored to a lower level from a higher level, EDK foundation will execute signaled events whose TPL value is larger than the lower level.


Q1: In UEFI spec, there is such a statement:

Only TPL_APPLICATION, TPL_CALLBACK, TPL_NOTIFY, and TPL_HIGH_LEVEL may be used.  All other values are reserved for use by the firmware; using them will result in unpredictable behavior.  Good coding practice dictates that all code should execute at its lowest possible TPL level, and the use of TPL levels above TPL_APPLICATION must be minimized.  Executing at TPL levels above TPL_APPLICATION for extended periods of time may also result in unpredictable behavior.


But in EDK implementation, you may see TPL_HIGH_LEVEL-1 is also used. It seems an exceptionJ. In theory, I think the value between 31 and 4 are feasible. But it depends on concrete implementation and may cause unpredictable behavior. As the four recommended values are designed by veteran architect, I think it is sufficient for your application.


Q2: From above, I think we have no process concept. If we want to execute some task, we need use time or event service to callback them.


If I misunderstand something, please feel free to point it out.


Tian Feng

From: Samuelraj, Daniel [mailto:Daniel.Samuelraj@lsi.com]
Sent: 2008
1011 5:06
To: dev@edk.tianocore.org
Subject: [EDK DEV] Questions regarding TPL



Can you please help answer below two questions

  1. Is all value possible between 1 to 30 for TPL?
  2. If there are two processes with same TPL and when one is running can it switch to another?