Subversion Repositories HelenOS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*++
  2.  
  3. Copyright (c) 1998  Intel Corporation
  4.  
  5. Module Name:
  6.  
  7.     lock.c
  8.  
  9. Abstract:
  10.  
  11.     Implements FLOCK
  12.  
  13.  
  14.  
  15. Revision History
  16.  
  17. --*/
  18.  
  19.  
  20. #include "lib.h"
  21.  
  22.  
  23. VOID
  24. InitializeLock (
  25.     IN OUT FLOCK    *Lock,
  26.     IN EFI_TPL      Priority
  27.     )
  28. /*++
  29.  
  30. Routine Description:
  31.  
  32.     Initialize a basic mutual exclusion lock.   Each lock
  33.     provides mutual exclusion access at it's task priority
  34.     level.  Since there is no-premption (at any TPL) or
  35.     multiprocessor support, acquiring the lock only consists
  36.     of raising to the locks TPL.
  37.  
  38.     Note on a debug build the lock is acquired and released
  39.     to help ensure proper usage.
  40.    
  41. Arguments:
  42.  
  43.     Lock        - The FLOCK structure to initialize
  44.  
  45.     Priority    - The task priority level of the lock
  46.  
  47.    
  48. Returns:
  49.  
  50.     An initialized F Lock structure.
  51.  
  52. --*/
  53. {
  54.     Lock->Tpl = Priority;
  55.     Lock->OwnerTpl = 0;
  56.     Lock->Lock = 0;
  57. }
  58.  
  59.  
  60. VOID
  61. AcquireLock (
  62.     IN FLOCK    *Lock
  63.     )
  64. /*++
  65.  
  66. Routine Description:
  67.  
  68.     Raising to the task priority level of the mutual exclusion
  69.     lock, and then acquires ownership of the lock.
  70.    
  71. Arguments:
  72.  
  73.     Lock        - The lock to acquire
  74.    
  75. Returns:
  76.  
  77.     Lock owned
  78.  
  79. --*/
  80. {
  81.     RtAcquireLock (Lock);
  82. }
  83.  
  84.  
  85. VOID
  86. ReleaseLock (
  87.     IN FLOCK    *Lock
  88.     )
  89. /*++
  90.  
  91. Routine Description:
  92.  
  93.     Releases ownership of the mutual exclusion lock, and
  94.     restores the previous task priority level.
  95.    
  96. Arguments:
  97.  
  98.     Lock        - The lock to release
  99.    
  100. Returns:
  101.  
  102.     Lock unowned
  103.  
  104. --*/
  105. {
  106.     RtReleaseLock (Lock);
  107. }
  108.