Skip to content

Commit

Permalink
- improved splinlock and busy-waiting barrier of cpp runtime
Browse files Browse the repository at this point in the history
- changed the busy wainting tests to n=2, so that they can be executed on dual core machines

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23756 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Marcus Walther committed Dec 12, 2014
1 parent 29158de commit a9c029a
Showing 1 changed file with 11 additions and 6 deletions.
Expand Up @@ -64,19 +64,24 @@ class busywaiting_barrier

class spinlock
{
boost::atomic_flag flag;
//boost::atomic_flag flag;
volatile bool locked;
public:
spinlock() {}
spinlock() : locked(false) {}

~spinlock() {}

void lock()
FORCE_INLINE void lock()
{
while(flag.test_and_set(boost::memory_order_acquire));
//while(flag.test_and_set(boost::memory_order_acquire));
while(locked) {}
locked = true;
}
void unlock()

FORCE_INLINE void unlock()
{
flag.clear(boost::memory_order_release);
//flag.clear(boost::memory_order_release);
locked = false;
}
};

Expand Down

0 comments on commit a9c029a

Please sign in to comment.