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
f0088aa7
authored
Jan 30, 2016
by
Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_c: changed task state attribute to atomic
mtapi_network_c: signaling of task completion is now atomic
parent
35ddd0d0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
10 deletions
+13
-10
mtapi_c/src/embb_mtapi_scheduler_t.c
+7
-4
mtapi_c/src/embb_mtapi_task_context_t.c
+1
-1
mtapi_c/src/embb_mtapi_task_t.c
+2
-2
mtapi_c/src/embb_mtapi_task_t.h
+1
-1
mtapi_network_c/src/embb_mtapi_network.c
+2
-2
No files found.
mtapi_c/src/embb_mtapi_scheduler_t.c
View file @
f0088aa7
...
...
@@ -302,7 +302,7 @@ int embb_mtapi_scheduler_worker(void * arg) {
node
->
queue_pool
,
task
->
queue
);
}
switch
(
task
->
state
)
{
switch
(
embb_atomic_load_int
(
&
task
->
state
)
)
{
case
MTAPI_TASK_SCHEDULED
:
/* multi-instance task, another instance might be running */
case
MTAPI_TASK_RUNNING
:
...
...
@@ -398,10 +398,11 @@ mtapi_boolean_t embb_mtapi_scheduler_wait_for_task(
node
->
scheduler
);
/* now wait and schedule new tasks if we are on a worker */
mtapi_task_state_t
task_state
=
embb_atomic_load_int
(
&
task
->
state
);
while
(
(
MTAPI_TASK_SCHEDULED
==
task
->
state
)
||
(
MTAPI_TASK_RUNNING
==
task
->
state
)
||
(
MTAPI_TASK_RETAINED
==
task
->
state
)
)
{
(
MTAPI_TASK_SCHEDULED
==
task
_
state
)
||
(
MTAPI_TASK_RUNNING
==
task
_
state
)
||
(
MTAPI_TASK_RETAINED
==
task
_
state
)
)
{
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
...
...
@@ -416,6 +417,8 @@ mtapi_boolean_t embb_mtapi_scheduler_wait_for_task(
node
->
scheduler
,
node
,
context
);
task_state
=
embb_atomic_load_int
(
&
task
->
state
);
}
return
MTAPI_TRUE
;
...
...
mtapi_c/src/embb_mtapi_task_context_t.c
View file @
f0088aa7
...
...
@@ -187,7 +187,7 @@ mtapi_task_state_t mtapi_context_taskstate_get(
&
(
task_context
->
thread_context
->
tss_id
));
if
(
local_context
==
task_context
->
thread_context
)
{
task_state
=
task_context
->
task
->
state
;
task_state
=
embb_atomic_load_int
(
&
task_context
->
task
->
state
)
;
local_status
=
MTAPI_SUCCESS
;
}
else
{
local_status
=
MTAPI_ERR_CONTEXT_OUTOFCONTEXT
;
...
...
mtapi_c/src/embb_mtapi_task_t.c
View file @
f0088aa7
...
...
@@ -79,7 +79,7 @@ void embb_mtapi_task_initialize(embb_mtapi_task_t* that) {
that
->
action
.
id
=
EMBB_MTAPI_IDPOOL_INVALID_ID
;
that
->
job
.
id
=
EMBB_MTAPI_IDPOOL_INVALID_ID
;
that
->
state
=
MTAPI_TASK_ERROR
;
embb_atomic_store_int
(
&
that
->
state
,
MTAPI_TASK_ERROR
)
;
that
->
task_id
=
MTAPI_TASK_ID_NONE
;
that
->
group
.
id
=
EMBB_MTAPI_IDPOOL_INVALID_ID
;
that
->
queue
.
id
=
EMBB_MTAPI_IDPOOL_INVALID_ID
;
...
...
@@ -159,7 +159,7 @@ void embb_mtapi_task_set_state(
assert
(
MTAPI_NULL
!=
that
);
embb_spin_lock
(
&
that
->
state_lock
);
that
->
state
=
state
;
embb_atomic_store_int
(
&
that
->
state
,
state
)
;
embb_atomic_memory_barrier
();
embb_spin_unlock
(
&
that
->
state_lock
);
}
...
...
mtapi_c/src/embb_mtapi_task_t.h
View file @
f0088aa7
...
...
@@ -66,7 +66,7 @@ struct embb_mtapi_task_struct {
mtapi_action_hndl_t
action
;
embb_spinlock_t
state_lock
;
volatile
mtapi_task_state_
t
state
;
embb_atomic_in
t
state
;
embb_atomic_unsigned_int
current_instance
;
embb_atomic_unsigned_int
instances_todo
;
...
...
mtapi_network_c/src/embb_mtapi_network.c
View file @
f0088aa7
...
...
@@ -377,7 +377,7 @@ static int embb_mtapi_network_thread(void * args) {
assert
(
err
==
results_size
);
local_task
->
error_code
=
(
mtapi_status_t
)
task_status
;
local_task
->
state
=
MTAPI_TASK_COMPLETED
;
embb_atomic_store_int
(
&
local_task
->
state
,
MTAPI_TASK_COMPLETED
)
;
embb_atomic_fetch_and_add_int
(
&
local_action
->
num_tasks
,
-
1
);
/* is task associated with a group? */
...
...
@@ -530,7 +530,7 @@ static void network_task_start(
assert
(
err
==
send_buf
->
size
);
embb_atomic_fetch_and_add_int
(
&
local_action
->
num_tasks
,
1
);
local_task
->
state
=
MTAPI_TASK_RUNNING
;
embb_atomic_store_int
(
&
local_task
->
state
,
MTAPI_TASK_RUNNING
)
;
embb_mtapi_network_buffer_clear
(
send_buf
);
...
...
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