Mark3 Realtime Kernel
atomic.cpp
Go to the documentation of this file.
1 /*===========================================================================
2  _____ _____ _____ _____
3  ___| _|__ __|_ |__ __|__ |__ __| __ |__ ______
4 | \ / | || \ || | || |/ / ||___ |
5 | \/ | || \ || \ || \ ||___ |
6 |__/\__/|__|_||__|\__\ __||__|\__\ __||__|\__\ __||______|
7  |_____| |_____| |_____| |_____|
8 
9 --[Mark3 Realtime Platform]--------------------------------------------------
10 
11 Copyright (c) 2012 - 2019 m0slevin, all rights reserved.
12 See license.txt for more information
13 ===========================================================================*/
21 #include "mark3.h"
22 
23 namespace Mark3
24 {
25 //---------------------------------------------------------------------------
26 bool Atomic::TestAndSet(bool* pbLock_)
27 {
28  KERNEL_ASSERT(nullptr != pbLock_);
29 
30  auto cs = CriticalGuard{};
31  auto bRet = *pbLock_;
32  if (!bRet) {
33  *pbLock_ = 1;
34  }
35  return bRet;
36 }
37 } // namespace Mark3
#define KERNEL_ASSERT(x)
Definition: kerneldebug.h:36
Definition: atomic.cpp:23
Single include file given to users of the Mark3 Kernel API.
bool TestAndSet(bool *pbLock)
TestAndSet Test to see if a variable is set, and set it if is not already set. This is an uninterrupt...
Definition: atomic.cpp:26
The CriticalGuard class. This class provides an implemention of RAII for critical sections...
Definition: criticalguard.h:38