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
053ca488
authored
9 years ago
by
Christian Kern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Worked on review comments for ticket #523
parent
a023d6e4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
55 deletions
+58
-55
base_c/src/internal/thread_index.c
+12
-6
containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h
+0
-0
containers_cpp/include/embb/containers/internal/hazard_pointer.h
+0
-0
containers_cpp/test/hazard_pointer_test.cc
+0
-0
containers_cpp/test/hazard_pointer_test.h
+46
-49
No files found.
base_c/src/internal/thread_index.c
View file @
053ca488
...
...
@@ -128,13 +128,19 @@ void embb_internal_thread_index_set_max(unsigned int max) {
*
embb_max_number_thread_indices
()
=
max
;
}
/**
* \pre the calling thread is the only active thread
*
* \post the thread indices count and calling thread index is reset
*/
void
embb_internal_thread_index_reset
()
{
// This function is only called in tests, usually when all other threads
// except the main thread have terminated. However, the main thread still has
// potentially still stored its old index value in its thread local storage,
// which might be assigned additionally to another thread (as the counter is
// reset), which may lead to hard to detect bugs. Therefore, reset the thread
// local thread id here.
/** This function is only called in tests, usually when all other threads
* except the main thread have terminated. However, the main thread still has
* potentially stored its old index value in its thread local storage,
* which might be assigned additionally to another thread (as the counter is
* reset), which may lead to hard to detect bugs. Therefore, reset the thread
* local thread id here.
*/
embb_internal_thread_index_var
=
UINT_MAX
;
embb_counter_init
(
embb_thread_index_counter
());
...
...
This diff is collapsed.
Click to expand it.
containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h
View file @
053ca488
This diff is collapsed.
Click to expand it.
containers_cpp/include/embb/containers/internal/hazard_pointer.h
View file @
053ca488
This diff is collapsed.
Click to expand it.
containers_cpp/test/hazard_pointer_test.cc
View file @
053ca488
This diff is collapsed.
Click to expand it.
containers_cpp/test/hazard_pointer_test.h
View file @
053ca488
...
...
@@ -36,7 +36,6 @@
namespace
embb
{
namespace
containers
{
namespace
test
{
/**
* @brief a very simple wait-free object pool implementation to have tests
* being independent of the EMBB object pool implementation.
...
...
@@ -51,7 +50,7 @@ class IntObjectTestPool {
static
const
int
FREE_MARKER
=
0
;
unsigned
int
poolSize
;
IntObjectTestPool
(
unsigned
int
pool
S
ize
);
IntObjectTestPool
(
unsigned
int
pool
_s
ize
);
~
IntObjectTestPool
();
...
...
@@ -67,27 +66,10 @@ class IntObjectTestPool {
*
* @param objectPointer the object to be freed
*/
void
Release
(
int
*
object
P
ointer
);
void
Release
(
int
*
object
_p
ointer
);
};
class
HazardPointerTest
:
public
partest
::
TestCase
{
private
:
embb
::
base
::
Function
<
void
,
embb
::
base
::
Atomic
<
int
>*>
deletePointerCallback
;
//used to allocate random stuff, we will just use the pointers, not the
//contents
embb
::
containers
::
ObjectPool
<
embb
::
base
::
Atomic
<
int
>
>*
objectPool
;
//used to move pointer between threads
embb
::
containers
::
LockFreeStack
<
embb
::
base
::
Atomic
<
int
>*
>*
stack
;
embb
::
base
::
Mutex
vectorMutex
;
embb
::
containers
::
internal
::
HazardPointer
<
embb
::
base
::
Atomic
<
int
>*>*
hazardPointer
;
std
::
vector
<
embb
::
base
::
Atomic
<
int
>*
>
deletedVector
;
int
nThreads
;
int
nElementsPerThread
;
int
nElements
;
public
:
/**
* Adds test methods.
...
...
@@ -96,56 +78,71 @@ class HazardPointerTest : public partest::TestCase {
void
HazardPointerTest1Pre
();
void
HazardPointerTest1Post
();
void
HazardPointerTest1ThreadMethod
();
void
DeletePointerCallback
(
embb
::
base
::
Atomic
<
int
>*
toDelete
);
void
DeletePointerCallback
(
embb
::
base
::
Atomic
<
int
>*
to_delete
);
private
:
embb
::
base
::
Function
<
void
,
embb
::
base
::
Atomic
<
int
>*>
delete_pointer_callback_
;
//used to allocate random stuff, we will just use the pointers, not the
//contents
embb
::
containers
::
ObjectPool
<
embb
::
base
::
Atomic
<
int
>
>*
object_pool_
;
//used to move pointer between threads
embb
::
containers
::
LockFreeStack
<
embb
::
base
::
Atomic
<
int
>*
>*
stack_
;
embb
::
base
::
Mutex
vector_mutex_
;
embb
::
containers
::
internal
::
HazardPointer
<
embb
::
base
::
Atomic
<
int
>*>*
hazard_pointer_
;
std
::
vector
<
embb
::
base
::
Atomic
<
int
>*
>
deleted_vector_
;
int
n_threads_
;
int
n_elements_per_thread_
;
int
n_elements_
;
};
class
HazardPointerTest2
:
public
partest
::
TestCase
{
public
:
void
DeletePointerCallback
(
int
*
to_delete
);
bool
SetRelativeGuards
();
void
HazardPointerTest2Master
();
void
HazardPointerTest2Slave
();
void
HazardPointerTest2Pre
();
void
HazardPointerTest2Post
();
void
HazardPointerTest2ThreadMethod
();
HazardPointerTest2
();
private
:
// number of threads, participating in that test
int
n
T
hreads
;
int
n
_t
hreads
;
embb
::
base
::
Function
<
void
,
int
*>
delete
PointerCallback
;
embb
::
base
::
Function
<
void
,
int
*>
delete
_pointer_callback_
;
// the thread id of the master
embb
::
base
::
Atomic
<
unsigned
int
>
current
Master
;
embb
::
base
::
Atomic
<
unsigned
int
>
current
_master_
;
// variables, to synchronize threads. At each point in time, one master,
// the master changes each round until each thread was assigned master once.
embb
::
base
::
Atomic
<
int
>
sync1
;
embb
::
base
::
Atomic
<
unsigned
int
>
sync2
;
embb
::
base
::
Atomic
<
int
>
sync1
_
;
embb
::
base
::
Atomic
<
unsigned
int
>
sync2
_
;
unsigned
int
guards
PerThreadCount
;
unsigned
int
guaranteed
CapacityPool
;
unsigned
int
pool
SizeUsingHazardPointer
;
unsigned
int
guards
_per_phread_count_
;
unsigned
int
guaranteed
_capacity_pool_
;
unsigned
int
pool
_size_using_hazard_pointer_
;
// The threads write here, if they guarded an object successfully. Used to
// determine when all allocated objects were guarded successfully.
embb
::
base
::
Atomic
<
int
*>*
shared
Guarded
;
embb
::
base
::
Atomic
<
int
*>*
shared
_guarded_
;
// This array is used by the master, to communicate and share what he has
// allocated with the slaves.
embb
::
base
::
Atomic
<
int
*>*
shared
Allocated
;
embb
::
base
::
Atomic
<
int
*>*
shared
_allocated_
;
// Reference to the object pool
IntObjectTestPool
*
testPool
;
embb
::
containers
::
internal
::
HazardPointer
<
int
*>*
hazardPointer
;
static
const
int
finishMarker
=
-
1
;
IntObjectTestPool
*
test_pool_
;
public
:
void
DeletePointerCallback
(
int
*
toDelete
);
bool
SetRelativeGuards
();
void
HazardPointerTest2Master
();
void
HazardPointerTest2Slave
();
void
HazardPointerTest2Pre
();
void
HazardPointerTest2Post
();
void
HazardPointerTest2ThreadMethod
();
HazardPointerTest2
();
embb
::
containers
::
internal
::
HazardPointer
<
int
*>*
hazard_pointer_
;
static
const
int
FINISH_MARKER
=
-
1
;
};
}
// namespace test
}
// namespace containers
}
// namespace embb
...
...
This diff is collapsed.
Click to expand it.
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