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
352d69e1
authored
8 years ago
by
Marcus Winter
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' into embb458_mtapi_initialization
parents
e1175972
7b0d2c67
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
4 deletions
+38
-4
mtapi_c/include/embb/mtapi/c/mtapi.h
+6
-1
mtapi_c/src/embb_mtapi_thread_context_t.c
+19
-1
mtapi_c/src/embb_mtapi_thread_context_t.h
+1
-0
mtapi_c/src/mtapi_node_attributes_t.c
+6
-0
mtapi_plugins_c/mtapi_network_c/test/embb_mtapi_network_test_socket.cc
+6
-2
No files found.
mtapi_c/include/embb/mtapi/c/mtapi.h
View file @
352d69e1
...
...
@@ -552,8 +552,9 @@ enum mtapi_node_attributes_enum {
the node */
MTAPI_NODE_MAX_ACTIONS_PER_JOB
,
/**< maximum number of actions in a job
allowed by the node */
MTAPI_NODE_MAX_PRIORITIES
/**< maximum number of priorities
MTAPI_NODE_MAX_PRIORITIES
,
/**< maximum number of priorities
allowed by the node */
MTAPI_NODE_REUSE_MAIN_THREAD
/**< reuse main thread as worker */
};
/** size of the \a MTAPI_NODE_CORE_AFFINITY attribute */
#define MTAPI_NODE_CORE_AFFINITY_SIZE sizeof(embb_core_set_t)
...
...
@@ -577,6 +578,8 @@ enum mtapi_node_attributes_enum {
#define MTAPI_NODE_MAX_ACTIONS_PER_JOB_SIZE sizeof(mtapi_uint_t)
/** size of the \a MTAPI_NODE_MAX_PRIORITIES attribute */
#define MTAPI_NODE_MAX_PRIORITIES_SIZE sizeof(mtapi_uint_t)
/** size of the \a MTAPI_NODE_REUSE_MAIN_THREAD attribute */
#define MTAPI_NODE_REUSE_MAIN_THREAD_SIZE sizeof(mtapi_boolean_t)
/* example attribute value */
#define MTAPI_NODE_TYPE_SMP 1
...
...
@@ -688,6 +691,8 @@ struct mtapi_node_attributes_struct {
mtapi_uint_t
max_actions_per_job
;
/**< stores
MTAPI_NODE_MAX_ACTIONS_PER_JOB */
mtapi_uint_t
max_priorities
;
/**< stores MTAPI_NODE_MAX_PRIORITIES */
mtapi_boolean_t
reuse_main_thread
;
/**< stores
MTAPI_NODE_REUSE_MAIN_THREAD */
};
/**
...
...
This diff is collapsed.
Click to expand it.
mtapi_c/src/embb_mtapi_thread_context_t.c
View file @
352d69e1
...
...
@@ -54,6 +54,7 @@ mtapi_boolean_t embb_mtapi_thread_context_initialize_with_node_worker_and_core(
that
->
core_num
=
core_num
;
that
->
priorities
=
node
->
attributes
.
max_priorities
;
that
->
is_initialized
=
MTAPI_FALSE
;
that
->
is_main_thread
=
(
worker_index
==
0
)
?
node
->
attributes
.
reuse_main_thread
:
MTAPI_FALSE
;
embb_atomic_store_int
(
&
that
->
run
,
0
);
that
->
queue
=
(
embb_mtapi_task_queue_t
**
)
embb_mtapi_alloc_allocate
(
...
...
@@ -121,6 +122,18 @@ mtapi_boolean_t embb_mtapi_thread_context_start(
embb_core_set_add
(
&
core_set
,
that
->
core_num
);
/* create thread */
if
(
that
->
is_main_thread
)
{
/* reuse main thread */
that
->
thread
=
embb_thread_current
();
err
=
embb_tss_create
(
&
that
->
tss_id
);
if
(
EMBB_SUCCESS
!=
err
)
{
/* report error to scheduler */
embb_atomic_store_int
(
&
that
->
run
,
-
1
);
return
MTAPI_FALSE
;
}
embb_tss_set
(
&
(
that
->
tss_id
),
that
);
embb_atomic_store_int
(
&
that
->
run
,
1
);
}
else
{
err
=
embb_thread_create
(
&
that
->
thread
,
&
core_set
,
worker_func
,
that
);
if
(
EMBB_SUCCESS
!=
err
)
{
embb_mtapi_log_error
(
...
...
@@ -128,11 +141,11 @@ mtapi_boolean_t embb_mtapi_thread_context_start(
"create thread %d on core %d
\n
"
,
that
->
worker_index
,
that
->
core_num
);
return
MTAPI_FALSE
;
}
/* wait for worker to come up */
while
(
0
==
embb_atomic_load_int
(
&
that
->
run
))
{
embb_thread_yield
();
}
}
if
(
0
<
embb_atomic_load_int
(
&
that
->
run
))
{
return
MTAPI_TRUE
;
...
...
@@ -146,8 +159,10 @@ void embb_mtapi_thread_context_stop(embb_mtapi_thread_context_t* that) {
if
(
0
<
embb_atomic_load_int
(
&
that
->
run
))
{
embb_atomic_store_int
(
&
that
->
run
,
0
);
embb_condition_notify_one
(
&
that
->
work_available
);
if
(
MTAPI_FALSE
==
that
->
is_main_thread
)
{
embb_thread_join
(
&
(
that
->
thread
),
&
result
);
}
}
}
void
embb_mtapi_thread_context_finalize
(
embb_mtapi_thread_context_t
*
that
)
{
...
...
@@ -158,6 +173,9 @@ void embb_mtapi_thread_context_finalize(embb_mtapi_thread_context_t* that) {
embb_mtapi_log_trace
(
"embb_mtapi_thread_context_finalize() called
\n
"
);
if
(
that
->
is_initialized
)
{
if
(
that
->
is_main_thread
)
{
embb_tss_delete
(
&
that
->
tss_id
);
}
embb_condition_destroy
(
&
that
->
work_available
);
embb_mutex_destroy
(
&
that
->
work_available_mutex
);
}
...
...
This diff is collapsed.
Click to expand it.
mtapi_c/src/embb_mtapi_thread_context_t.h
View file @
352d69e1
...
...
@@ -68,6 +68,7 @@ struct embb_mtapi_thread_context_struct {
embb_atomic_int
run
;
mtapi_status_t
status
;
mtapi_boolean_t
is_initialized
;
mtapi_boolean_t
is_main_thread
;
};
#include <embb_mtapi_thread_context_t_fwd.h>
...
...
This diff is collapsed.
Click to expand it.
mtapi_c/src/mtapi_node_attributes_t.c
View file @
352d69e1
...
...
@@ -52,6 +52,7 @@ void mtapi_nodeattr_init(
attributes
->
max_jobs
=
MTAPI_NODE_MAX_JOBS_DEFAULT
;
attributes
->
max_actions_per_job
=
MTAPI_NODE_MAX_ACTIONS_PER_JOB_DEFAULT
;
attributes
->
max_priorities
=
MTAPI_NODE_MAX_PRIORITIES_DEFAULT
;
attributes
->
reuse_main_thread
=
MTAPI_FALSE
;
embb_core_set_init
(
&
attributes
->
core_affinity
,
1
);
attributes
->
num_cores
=
embb_core_set_count
(
&
attributes
->
core_affinity
);
...
...
@@ -143,6 +144,11 @@ void mtapi_nodeattr_set(
&
attributes
->
max_priorities
,
attribute
,
attribute_size
);
break
;
case
MTAPI_NODE_REUSE_MAIN_THREAD
:
local_status
=
embb_mtapi_attr_set_mtapi_boolean_t
(
&
attributes
->
reuse_main_thread
,
attribute
,
attribute_size
);
break
;
default:
/* attribute unknown */
local_status
=
MTAPI_ERR_ATTR_NUM
;
...
...
This diff is collapsed.
Click to expand it.
mtapi_plugins_c/mtapi_network_c/test/embb_mtapi_network_test_socket.cc
View file @
352d69e1
...
...
@@ -53,8 +53,12 @@ void NetworkSocketTest::TestBasic() {
err
=
embb_mtapi_network_socket_initialize
(
&
server_sock
);
PT_EXPECT
(
err
!=
0
);
uint16_t
port
=
4700
;
do
{
port
++
;
err
=
embb_mtapi_network_socket_bind_and_listen
(
&
server_sock
,
"127.0.0.1"
,
4711
,
5
);
&
server_sock
,
"127.0.0.1"
,
port
,
5
);
}
while
(
err
==
0
&&
port
<
4800
);
PT_EXPECT
(
err
!=
0
);
err
=
embb_mtapi_network_socket_select
(
&
server_sock
,
1
,
1
);
...
...
@@ -62,7 +66,7 @@ void NetworkSocketTest::TestBasic() {
err
=
embb_mtapi_network_socket_initialize
(
&
client_sock
);
PT_EXPECT
(
err
!=
0
);
err
=
embb_mtapi_network_socket_connect
(
&
client_sock
,
"127.0.0.1"
,
4711
);
err
=
embb_mtapi_network_socket_connect
(
&
client_sock
,
"127.0.0.1"
,
port
);
PT_EXPECT
(
err
!=
0
);
err
=
embb_mtapi_network_socket_select
(
&
server_sock
,
1
,
-
1
);
...
...
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