Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c4e54809
authored
Nov 23, 2015
by
bernhard-gatzhammer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'embb509_centralize_spinlocks' into development
parents
d12883aa
6042e5f8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
9 additions
and
10 deletions
+9
-10
base_c/src/mutex.c
+0
-1
base_c/test/mutex_test.cc
+2
-2
base_c/test/mutex_test.h
+1
-0
base_cpp/src/mutex.cc
+2
-3
base_cpp/test/mutex_test.cc
+2
-2
base_cpp/test/mutex_test.h
+2
-2
No files found.
base_c/src/mutex.c
View file @
c4e54809
...
@@ -163,5 +163,4 @@ int embb_spin_unlock(embb_spinlock_t* spinlock) {
...
@@ -163,5 +163,4 @@ int embb_spin_unlock(embb_spinlock_t* spinlock) {
void
embb_spin_destroy
(
embb_spinlock_t
*
spinlock
)
{
void
embb_spin_destroy
(
embb_spinlock_t
*
spinlock
)
{
// for now, doing nothing here... in future, will call the respective
// for now, doing nothing here... in future, will call the respective
// destroy function for atomics...
// destroy function for atomics...
return
EMBB_SUCCESS
;
}
}
base_c/test/mutex_test.cc
View file @
c4e54809
...
@@ -124,7 +124,7 @@ void SpinLockTest::PreSpinLockInc() {
...
@@ -124,7 +124,7 @@ void SpinLockTest::PreSpinLockInc() {
}
}
void
SpinLockTest
::
TestSpinLockIncUseLock
()
{
void
SpinLockTest
::
TestSpinLockIncUseLock
()
{
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
){
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
)
{
embb_spin_lock
(
&
spinlock_
);
embb_spin_lock
(
&
spinlock_
);
counter_
++
;
counter_
++
;
embb_spin_unlock
(
&
spinlock_
);
embb_spin_unlock
(
&
spinlock_
);
...
@@ -132,7 +132,7 @@ void SpinLockTest::TestSpinLockIncUseLock() {
...
@@ -132,7 +132,7 @@ void SpinLockTest::TestSpinLockIncUseLock() {
}
}
void
SpinLockTest
::
TestSpinLockIncUseTryLock
()
{
void
SpinLockTest
::
TestSpinLockIncUseTryLock
()
{
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
){
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
)
{
while
(
embb_spin_try_lock
(
&
spinlock_
,
100
)
!=
EMBB_SUCCESS
)
{}
while
(
embb_spin_try_lock
(
&
spinlock_
,
100
)
!=
EMBB_SUCCESS
)
{}
counter_
++
;
counter_
++
;
embb_spin_unlock
(
&
spinlock_
);
embb_spin_unlock
(
&
spinlock_
);
...
...
base_c/test/mutex_test.h
View file @
c4e54809
...
@@ -89,6 +89,7 @@ class MutexTest : public partest::TestCase {
...
@@ -89,6 +89,7 @@ class MutexTest : public partest::TestCase {
class
SpinLockTest
:
public
partest
::
TestCase
{
class
SpinLockTest
:
public
partest
::
TestCase
{
public
:
public
:
SpinLockTest
();
SpinLockTest
();
private
:
private
:
/**
/**
* Check that the try lock fails, when lock is already set.
* Check that the try lock fails, when lock is already set.
...
...
base_cpp/src/mutex.cc
View file @
c4e54809
...
@@ -81,10 +81,9 @@ void Spinlock::Lock() {
...
@@ -81,10 +81,9 @@ void Spinlock::Lock() {
bool
Spinlock
::
TryLock
(
unsigned
int
number_spins
)
{
bool
Spinlock
::
TryLock
(
unsigned
int
number_spins
)
{
int
status
=
embb_spin_try_lock
(
&
spinlock_
,
number_spins
);
int
status
=
embb_spin_try_lock
(
&
spinlock_
,
number_spins
);
if
(
status
==
EMBB_BUSY
){
if
(
status
==
EMBB_BUSY
)
{
return
false
;
return
false
;
}
}
else
if
(
status
!=
EMBB_SUCCESS
)
{
else
if
(
status
!=
EMBB_SUCCESS
)
{
EMBB_THROW
(
ErrorException
,
"Error while try-locking spinlock"
);
EMBB_THROW
(
ErrorException
,
"Error while try-locking spinlock"
);
}
}
...
...
base_cpp/test/mutex_test.cc
View file @
c4e54809
...
@@ -227,7 +227,7 @@ number_threads_(partest::TestSuite::GetDefaultNumThreads()),
...
@@ -227,7 +227,7 @@ number_threads_(partest::TestSuite::GetDefaultNumThreads()),
}
}
void
SpinLockTest
::
TestSpinlockCountLock
()
{
void
SpinLockTest
::
TestSpinlockCountLock
()
{
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
){
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
)
{
spinlock_
.
Lock
();
spinlock_
.
Lock
();
counter_
++
;
counter_
++
;
spinlock_
.
Unlock
();
spinlock_
.
Unlock
();
...
@@ -235,7 +235,7 @@ void SpinLockTest::TestSpinlockCountLock() {
...
@@ -235,7 +235,7 @@ void SpinLockTest::TestSpinlockCountLock() {
}
}
void
SpinLockTest
::
TestSpinlockCountLockTryLock
()
{
void
SpinLockTest
::
TestSpinlockCountLockTryLock
()
{
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
){
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
)
{
while
(
!
spinlock_
.
TryLock
())
{}
while
(
!
spinlock_
.
TryLock
())
{}
counter_
++
;
counter_
++
;
spinlock_
.
Unlock
();
spinlock_
.
Unlock
();
...
...
base_cpp/test/mutex_test.h
View file @
c4e54809
...
@@ -90,10 +90,10 @@ class MutexTest : public partest::TestCase {
...
@@ -90,10 +90,10 @@ class MutexTest : public partest::TestCase {
};
};
class
SpinLockTest
:
public
partest
::
TestCase
{
class
SpinLockTest
:
public
partest
::
TestCase
{
public
:
public
:
SpinLockTest
();
SpinLockTest
();
private
:
private
:
/**
/**
* Uses Spinlock to realize multi-threaded counting.
* Uses Spinlock to realize multi-threaded counting.
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment