Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Tobias Langer
/
experiment
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
0512b30f
authored
Oct 09, 2016
by
Tobias Langer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixes with timing and task termination.
parent
0c8665f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
+23
-5
templates/normal/experiment.cpp
+23
-5
No files found.
templates/normal/experiment.cpp
View file @
0512b30f
...
...
@@ -127,11 +127,19 @@ static void TaskStarter()
auto
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
/* Storage for any task which is started. */
std
::
vector
<
embb
::
mtapi
::
Task
>
running
;
/* Storage for task parameters. */
std
::
vector
<
std
::
pair
<
int
,
int
>>
running_num
;
auto
hyperperiod
=
calculate_hyperperiod
();
/* Storage for task parameters. */
int
task_cnt
=
0
;
for
(
int
i
=
0
;
i
<
taskset_length
;
i
++
)
{
node
.
CreateAction
(
ACTION_ID
+
i
+
1
,
IdleTask
);
task_cnt
+=
hyperperiod
/
taskset
[
i
].
period
;
std
::
cout
<<
"Task "
<<
i
<<
" wcet: "
<<
taskset
[
i
].
wcet
<<
" period: "
<<
taskset
[
i
].
period
<<
" deadline: "
<<
taskset
[
i
].
deadline
<<
std
::
endl
;
}
std
::
vector
<
std
::
pair
<
int
,
int
>>
running_num
(
task_cnt
);
int
task_ptr
=
0
;
using
namespace
std
::
chrono
;
start
=
base_clock
::
now
();
...
...
@@ -169,11 +177,10 @@ static void TaskStarter()
* to make sure that all possible running tasks can access their
* parameters.
*/
running_num
.
push_back
(
std
::
make_pair
(
i
,
count
));
node
.
CreateAction
(
ACTION_ID
+
i
+
1
,
IdleTask
);
running_num
[
task_ptr
++
]
=
std
::
make_pair
(
i
,
count
);
auto
job
=
node
.
GetJob
(
ACTION_ID
+
i
+
1
,
DOMAIN_ID
);
int
tmp
;
auto
t
=
node
.
Start
(
job
,
&
running_num
.
back
()
,
&
tmp
);
int
tmp
;
auto
t
=
node
.
Start
(
job
,
&
running_num
[
task_ptr
-
1
]
,
&
tmp
);
/* Store task to wait for it. */
running
.
push_back
(
t
);
...
...
@@ -181,6 +188,17 @@ static void TaskStarter()
}
}
auto
wait_start
=
base_clock
::
now
();
while
(
min
.
count
()
>
0
&&
running
.
size
()
>
0
)
{
auto
status
=
running
.
front
().
Wait
(
min
.
count
());
// TODO factor for anything bigger than milliseconds
if
(
status
==
MTAPI_SUCCESS
)
{
running
.
erase
(
running
.
begin
());
}
auto
remain
=
duration_cast
<
cpp_time_base
>
(
wait_start
-
base_clock
::
now
());
if
(
remain
.
count
()
>
0
)
{
min
-=
remain
;
}
}
std
::
this_thread
::
sleep_for
(
min
);
cur_time
=
duration_cast
<
cpp_time_base
>
(
base_clock
::
now
()
-
start
);
}
...
...
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