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
6042e5f8
authored
Nov 23, 2015
by
bernhard-gatzhammer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved codestyle and removed return in void spinlock destroy.
EMBB-509
parent
5bc9ff94
Hide 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 @
6042e5f8
...
...
@@ -163,5 +163,4 @@ int embb_spin_unlock(embb_spinlock_t* spinlock) {
void
embb_spin_destroy
(
embb_spinlock_t
*
spinlock
)
{
// for now, doing nothing here... in future, will call the respective
// destroy function for atomics...
return
EMBB_SUCCESS
;
}
base_c/test/mutex_test.cc
View file @
6042e5f8
...
...
@@ -124,7 +124,7 @@ void SpinLockTest::PreSpinLockInc() {
}
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_
);
counter_
++
;
embb_spin_unlock
(
&
spinlock_
);
...
...
@@ -132,7 +132,7 @@ void SpinLockTest::TestSpinLockIncUseLock() {
}
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
)
{}
counter_
++
;
embb_spin_unlock
(
&
spinlock_
);
...
...
base_c/test/mutex_test.h
View file @
6042e5f8
...
...
@@ -89,6 +89,7 @@ class MutexTest : public partest::TestCase {
class
SpinLockTest
:
public
partest
::
TestCase
{
public
:
SpinLockTest
();
private
:
/**
* Check that the try lock fails, when lock is already set.
...
...
base_cpp/src/mutex.cc
View file @
6042e5f8
...
...
@@ -81,10 +81,9 @@ void Spinlock::Lock() {
bool
Spinlock
::
TryLock
(
unsigned
int
number_spins
)
{
int
status
=
embb_spin_try_lock
(
&
spinlock_
,
number_spins
);
if
(
status
==
EMBB_BUSY
){
if
(
status
==
EMBB_BUSY
)
{
return
false
;
}
else
if
(
status
!=
EMBB_SUCCESS
)
{
}
else
if
(
status
!=
EMBB_SUCCESS
)
{
EMBB_THROW
(
ErrorException
,
"Error while try-locking spinlock"
);
}
...
...
base_cpp/test/mutex_test.cc
View file @
6042e5f8
...
...
@@ -227,7 +227,7 @@ number_threads_(partest::TestSuite::GetDefaultNumThreads()),
}
void
SpinLockTest
::
TestSpinlockCountLock
()
{
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
){
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
)
{
spinlock_
.
Lock
();
counter_
++
;
spinlock_
.
Unlock
();
...
...
@@ -235,7 +235,7 @@ void SpinLockTest::TestSpinlockCountLock() {
}
void
SpinLockTest
::
TestSpinlockCountLockTryLock
()
{
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
){
for
(
unsigned
int
i
=
0
;
i
!=
counter_iterations_
;
++
i
)
{
while
(
!
spinlock_
.
TryLock
())
{}
counter_
++
;
spinlock_
.
Unlock
();
...
...
base_cpp/test/mutex_test.h
View file @
6042e5f8
...
...
@@ -90,10 +90,10 @@ class MutexTest : public partest::TestCase {
};
class
SpinLockTest
:
public
partest
::
TestCase
{
public
:
public
:
SpinLockTest
();
private
:
private
:
/**
* 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