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
05ec2f80
authored
Mar 12, 2015
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_c: only notify workers if they are actually sleeping
parent
7f7e33d2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
0 deletions
+6
-0
mtapi_c/src/embb_mtapi_scheduler_t.c
+4
-0
mtapi_c/src/embb_mtapi_thread_context_t.c
+1
-0
mtapi_c/src/embb_mtapi_thread_context_t.h
+1
-0
No files found.
mtapi_c/src/embb_mtapi_scheduler_t.c
View file @
05ec2f80
...
...
@@ -356,12 +356,14 @@ int embb_mtapi_scheduler_worker(void * arg) {
counter
++
;
}
else
{
/* no work, go to sleep */
embb_atomic_store_int
(
&
thread_context
->
is_sleeping
,
1
);
embb_mutex_lock
(
&
thread_context
->
work_available_mutex
);
embb_condition_wait_for
(
&
thread_context
->
work_available
,
&
thread_context
->
work_available_mutex
,
&
sleep_duration
);
embb_mutex_unlock
(
&
thread_context
->
work_available_mutex
);
embb_atomic_store_int
(
&
thread_context
->
is_sleeping
,
0
);
}
}
...
...
@@ -593,8 +595,10 @@ mtapi_boolean_t embb_mtapi_scheduler_schedule_task(
if
(
pushed
)
{
/* signal the worker thread a task was pushed to */
if
(
embb_atomic_load_int
(
&
scheduler
->
worker_contexts
[
ii
].
is_sleeping
))
{
embb_condition_notify_one
(
&
scheduler
->
worker_contexts
[
ii
].
work_available
);
}
}
else
{
/* task could not be launched */
embb_atomic_fetch_and_add_int
(
&
local_action
->
num_tasks
,
-
1
);
...
...
mtapi_c/src/embb_mtapi_thread_context_t.c
View file @
05ec2f80
...
...
@@ -70,6 +70,7 @@ void embb_mtapi_thread_context_initialize_with_node_worker_and_core(
embb_mutex_init
(
&
that
->
work_available_mutex
,
EMBB_MUTEX_PLAIN
);
embb_condition_init
(
&
that
->
work_available
);
embb_atomic_store_int
(
&
that
->
is_sleeping
,
0
);
}
mtapi_boolean_t
embb_mtapi_thread_context_start
(
...
...
mtapi_c/src/embb_mtapi_thread_context_t.h
View file @
05ec2f80
...
...
@@ -56,6 +56,7 @@ struct embb_mtapi_thread_context_struct {
embb_condition_t
work_available
;
embb_thread_t
thread
;
embb_tss_t
tss_id
;
embb_atomic_int
is_sleeping
;
embb_mtapi_node_t
*
node
;
embb_mtapi_task_queue_t
**
queue
;
...
...
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