package ti.sysbios.gates

Contains modules that inherit from IGatePovider

The xdc.runtime.Gate module is provided by XDCtools, and is documented in the XDCtools help, but SYS/BIOS provides additional implementations in the ti.sysbios.gates package. [ more ... ]
XDCspec declarations sourced in ti/sysbios/gates/package.xdc
requires ti.sysbios.knl;
 
package ti.sysbios.gates [2, 0, 0, 0] {
 
    module GateAll;
    // Hwi, Swi & Task Gate
    module GateHwi;
    // Hardware Interrupt Gate
    module GateMutex;
    // Mutex Gate
    module GateMutexPri;
    // Mutex Gate with priority inheritance
    module GateSwi;
    // Software Interrupt Gate
    module GateTask;
    // Task Gate
}
DETAILS
The xdc.runtime.Gate module is provided by XDCtools, and is documented in the XDCtools help, but SYS/BIOS provides additional implementations in the ti.sysbios.gates package.
A "Gate" is a module that implements the IGateProvider interface. Gates are devices for preventing concurrent accesses to critical regions of code. The various Gate implementations differ in how they attempt to lock the critical regions.
Threads can be preempted by other threads of higher priority, and some sections of code need to be completed by one thread before they can be executed by another thread. Code that modifies a linked list is a common example of a critical region that may need to be protected by a Gate.
Gates generally work by either disabling some level of preemption such as disabling task switching or even hardware interrupts, or by using a binary semaphore.
All Gate implementations support nesting through the use of a "key". For Gates that function by disabling preemption, it is possible that multiple threads would call Gate_enter(), but preemption should not be restored until all of the threads have called Gate_leave(). This functionality is provided through the use of a key. A call to Gate_enter() returns a key that must then be passed back to Gate_leave(). Only the outermost call to Gate_enter() returns the correct key for restoring preemption. (The actual module name for the implementation is used instead of "Gate" in the function name.)
RUNTIME EXAMPLE
The following C code protects a critical region with a Gate. This example uses a GateHwi, which disables and enables interrupts as the locking mechanism.
  UInt gateKey;
  GateHwi_Handle gateHwi;
  GateHwi_Params prms;
  GateHwi_Params_init(&prms);
  
  gateHwi = GateHwi_create(&prms, NULL);
  
  // Simultaneous operations on a List by multiple threads could
  // corrupt the List structure, so modifications to the List 
  // are protected with a Gate. 
  gateKey = GateHwi_enter(gateHwi);
  List_get(myList);
  GateHwi_leave(gateHwi, gateKey);
generated on Thu, 25 May 2017 22:10:07 GMT