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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
mtapi_c/src/embb_mtapi_scheduler_t.c
+6
-2
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) {
...
@@ -356,12 +356,14 @@ int embb_mtapi_scheduler_worker(void * arg) {
counter
++
;
counter
++
;
}
else
{
}
else
{
/* no work, go to sleep */
/* no work, go to sleep */
embb_atomic_store_int
(
&
thread_context
->
is_sleeping
,
1
);
embb_mutex_lock
(
&
thread_context
->
work_available_mutex
);
embb_mutex_lock
(
&
thread_context
->
work_available_mutex
);
embb_condition_wait_for
(
embb_condition_wait_for
(
&
thread_context
->
work_available
,
&
thread_context
->
work_available
,
&
thread_context
->
work_available_mutex
,
&
thread_context
->
work_available_mutex
,
&
sleep_duration
);
&
sleep_duration
);
embb_mutex_unlock
(
&
thread_context
->
work_available_mutex
);
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(
...
@@ -593,8 +595,10 @@ mtapi_boolean_t embb_mtapi_scheduler_schedule_task(
if
(
pushed
)
{
if
(
pushed
)
{
/* signal the worker thread a task was pushed to */
/* signal the worker thread a task was pushed to */
embb_condition_notify_one
(
if
(
embb_atomic_load_int
(
&
scheduler
->
worker_contexts
[
ii
].
is_sleeping
))
{
&
scheduler
->
worker_contexts
[
ii
].
work_available
);
embb_condition_notify_one
(
&
scheduler
->
worker_contexts
[
ii
].
work_available
);
}
}
else
{
}
else
{
/* task could not be launched */
/* task could not be launched */
embb_atomic_fetch_and_add_int
(
&
local_action
->
num_tasks
,
-
1
);
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(
...
@@ -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_mutex_init
(
&
that
->
work_available_mutex
,
EMBB_MUTEX_PLAIN
);
embb_condition_init
(
&
that
->
work_available
);
embb_condition_init
(
&
that
->
work_available
);
embb_atomic_store_int
(
&
that
->
is_sleeping
,
0
);
}
}
mtapi_boolean_t
embb_mtapi_thread_context_start
(
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 {
...
@@ -56,6 +56,7 @@ struct embb_mtapi_thread_context_struct {
embb_condition_t
work_available
;
embb_condition_t
work_available
;
embb_thread_t
thread
;
embb_thread_t
thread
;
embb_tss_t
tss_id
;
embb_tss_t
tss_id
;
embb_atomic_int
is_sleeping
;
embb_mtapi_node_t
*
node
;
embb_mtapi_node_t
*
node
;
embb_mtapi_task_queue_t
**
queue
;
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