Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
predictable_parallel_patterns
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
6027f7be
authored
Jan 26, 2020
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: add missing .cpp file to last commit.
parent
eecbe38d
Pipeline
#1387
failed with stages
in 26 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
lib/pls/src/internal/scheduling/task_manager.cpp
+73
-0
No files found.
lib/pls/src/internal/scheduling/task_manager.cpp
0 → 100644
View file @
6027f7be
#include "pls/internal/scheduling/task_manager.h"
#include "pls/internal/scheduling/task.h"
#include "pls/internal/scheduling/thread_state.h"
namespace
pls
{
namespace
internal
{
namespace
scheduling
{
task_manager
::
task_manager
(
task
*
tasks
,
data_structures
::
aligned_stack
static_stack_space
,
size_t
num_tasks
,
size_t
stack_size
,
external_trading_deque
&
deque
)
:
num_tasks_
{
num_tasks
},
this_thread_tasks_
{
tasks
},
active_task_
{
&
tasks
[
0
]},
deque_
{
deque
}
{
for
(
size_t
i
=
0
;
i
<
num_tasks
-
1
;
i
++
)
{
tasks
[
i
].
init
(
static_stack_space
.
push_bytes
(
stack_size
),
stack_size
,
i
,
0
);
if
(
i
>
0
)
{
tasks
[
i
].
prev_
=
&
tasks
[
i
-
1
];
}
if
(
i
<
num_tasks
-
2
)
{
tasks
[
i
].
next_
=
&
tasks
[
i
+
1
];
}
}
}
static
task
*
find_task
(
unsigned
id
,
unsigned
depth
)
{
return
thread_state
::
get
().
get_scheduler
().
thread_state_for
(
id
).
get_task_manager
().
get_this_thread_task
(
depth
);
}
void
task_manager
::
push_resource_on_task
(
task
*
target_task
,
task
*
spare_task_chain
)
{
data_structures
::
stamped_integer
current_root
;
data_structures
::
stamped_integer
target_root
;
do
{
current_root
=
target_task
->
resource_stack_root_
.
load
();
target_root
.
stamp
=
current_root
.
stamp
+
1
;
target_root
.
value
=
spare_task_chain
->
thread_id_
+
1
;
if
(
current_root
.
value
==
0
)
{
// Empty, simply push in with no successor
spare_task_chain
->
resource_stack_next_
=
nullptr
;
}
else
{
// Already an entry. Find it's corresponding task and set it as our successor.
auto
*
current_root_task
=
find_task
(
current_root
.
value
,
target_task
->
depth_
);
spare_task_chain
->
resource_stack_next_
=
current_root_task
;
}
}
while
(
target_task
->
resource_stack_root_
.
compare_exchange_strong
(
current_root
,
target_root
));
}
task
*
task_manager
::
pop_resource_from_task
(
task
*
target_task
)
{
data_structures
::
stamped_integer
current_root
;
data_structures
::
stamped_integer
target_root
;
do
{
current_root
=
target_task
->
resource_stack_root_
.
load
();
target_root
.
stamp
=
current_root
.
stamp
+
1
;
if
(
current_root
.
value
==
0
)
{
// Empty...
return
nullptr
;
}
else
{
// Found something, try to pop it
auto
*
current_root_task
=
find_task
(
current_root
.
value
-
1
,
target_task
->
depth_
);
target_root
.
value
=
current_root_task
->
next_
!=
nullptr
?
current_root_task
->
next_
->
thread_id_
+
1
:
0
;
}
}
while
(
target_task
->
resource_stack_root_
.
compare_exchange_strong
(
current_root
,
target_root
));
}
}
}
}
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