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
5c73ee43
authored
Jun 21, 2016
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtapi_c: fixed problem with non monotonic time readings and timeouts
parent
04ead31a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
0 deletions
+56
-0
mtapi_c/src/embb_mtapi_action_t.c
+16
-0
mtapi_c/src/embb_mtapi_group_t.c
+16
-0
mtapi_c/src/embb_mtapi_queue_t.c
+16
-0
mtapi_c/src/embb_mtapi_scheduler_t.c
+8
-0
No files found.
mtapi_c/src/embb_mtapi_action_t.c
View file @
5c73ee43
...
...
@@ -289,10 +289,12 @@ void mtapi_action_delete(
embb_mtapi_thread_context_t
*
context
=
NULL
;
embb_duration_t
wait_duration
;
embb_time_t
start_time
;
embb_time_t
end_time
;
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_duration_set_milliseconds
(
&
wait_duration
,
(
unsigned
long
long
)
timeout
);
embb_time_now
(
&
start_time
);
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
...
...
@@ -309,6 +311,12 @@ void mtapi_action_delete(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
if
(
embb_time_compare
(
&
current_time
,
&
start_time
)
<
0
)
{
/* time has moved backwards, maybe a wraparound or jitter
move end_time backward to avoid endeless loop */
start_time
=
current_time
;
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
if
(
embb_time_compare
(
&
current_time
,
&
end_time
)
>
0
)
{
/* timeout! */
local_status
=
MTAPI_TIMEOUT
;
...
...
@@ -362,10 +370,12 @@ void mtapi_action_disable(
embb_mtapi_thread_context_t
*
context
=
NULL
;
embb_duration_t
wait_duration
;
embb_time_t
start_time
;
embb_time_t
end_time
;
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_duration_set_milliseconds
(
&
wait_duration
,
(
unsigned
long
long
)
timeout
);
embb_time_now
(
&
start_time
);
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
...
...
@@ -382,6 +392,12 @@ void mtapi_action_disable(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
if
(
embb_time_compare
(
&
current_time
,
&
start_time
)
<
0
)
{
/* time has moved backwards, maybe a wraparound or jitter
move end_time backward to avoid endeless loop */
start_time
=
current_time
;
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
if
(
embb_time_compare
(
&
current_time
,
&
end_time
)
>
0
)
{
/* timeout! */
local_status
=
MTAPI_TIMEOUT
;
...
...
mtapi_c/src/embb_mtapi_group_t.c
View file @
5c73ee43
...
...
@@ -213,10 +213,12 @@ void mtapi_group_wait_all(
node
->
group_pool
,
group
);
embb_duration_t
wait_duration
;
embb_time_t
start_time
;
embb_time_t
end_time
;
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_duration_set_milliseconds
(
&
wait_duration
,
(
unsigned
long
long
)
timeout
);
embb_time_now
(
&
start_time
);
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
...
...
@@ -232,6 +234,12 @@ void mtapi_group_wait_all(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
if
(
embb_time_compare
(
&
current_time
,
&
start_time
)
<
0
)
{
/* time has moved backwards, maybe a wraparound or jitter
move end_time backward to avoid endeless loop */
start_time
=
current_time
;
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
if
(
embb_time_compare
(
&
current_time
,
&
end_time
)
>
0
)
{
/* timeout! */
local_status
=
MTAPI_TIMEOUT
;
...
...
@@ -300,10 +308,12 @@ void mtapi_group_wait_any(
embb_mtapi_thread_context_t
*
context
=
NULL
;
embb_duration_t
wait_duration
;
embb_time_t
start_time
;
embb_time_t
end_time
;
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_duration_set_milliseconds
(
&
wait_duration
,
(
unsigned
long
long
)
timeout
);
embb_time_now
(
&
start_time
);
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
...
...
@@ -318,6 +328,12 @@ void mtapi_group_wait_any(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
if
(
embb_time_compare
(
&
current_time
,
&
start_time
)
<
0
)
{
/* time has moved backwards, maybe a wraparound or jitter
move end_time backward to avoid endeless loop */
start_time
=
current_time
;
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
if
(
embb_time_compare
(
&
current_time
,
&
end_time
)
>
0
)
{
/* timeout! */
local_status
=
MTAPI_TIMEOUT
;
...
...
mtapi_c/src/embb_mtapi_queue_t.c
View file @
5c73ee43
...
...
@@ -360,10 +360,12 @@ void mtapi_queue_delete(
embb_mtapi_thread_context_t
*
context
=
NULL
;
embb_duration_t
wait_duration
;
embb_time_t
start_time
;
embb_time_t
end_time
;
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_duration_set_milliseconds
(
&
wait_duration
,
(
unsigned
long
long
)
timeout
);
embb_time_now
(
&
start_time
);
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
...
...
@@ -381,6 +383,12 @@ void mtapi_queue_delete(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
if
(
embb_time_compare
(
&
current_time
,
&
start_time
)
<
0
)
{
/* time has moved backwards, maybe a wraparound or jitter
move end_time backward to avoid endeless loop */
start_time
=
current_time
;
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
if
(
embb_time_compare
(
&
current_time
,
&
end_time
)
>
0
)
{
/* timeout! */
local_status
=
MTAPI_TIMEOUT
;
...
...
@@ -435,10 +443,12 @@ void mtapi_queue_disable(
embb_mtapi_scheduler_get_current_thread_context
(
node
->
scheduler
);
embb_duration_t
wait_duration
;
embb_time_t
start_time
;
embb_time_t
end_time
;
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_duration_set_milliseconds
(
&
wait_duration
,
(
unsigned
long
long
)
timeout
);
embb_time_now
(
&
start_time
);
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
...
...
@@ -448,6 +458,12 @@ void mtapi_queue_disable(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
if
(
embb_time_compare
(
&
current_time
,
&
start_time
)
<
0
)
{
/* time has moved backwards, maybe a wraparound or jitter
move end_time backward to avoid endeless loop */
start_time
=
current_time
;
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
if
(
embb_time_compare
(
&
current_time
,
&
end_time
)
>
0
)
{
/* timeout! */
local_status
=
MTAPI_TIMEOUT
;
...
...
mtapi_c/src/embb_mtapi_scheduler_t.c
View file @
5c73ee43
...
...
@@ -407,6 +407,7 @@ mtapi_boolean_t embb_mtapi_scheduler_wait_for_task(
embb_mtapi_node_t
*
node
=
embb_mtapi_node_get_instance
();
embb_mtapi_thread_context_t
*
context
=
NULL
;
embb_duration_t
wait_duration
;
embb_time_t
start_time
;
embb_time_t
end_time
;
assert
(
MTAPI_NULL
!=
node
);
...
...
@@ -414,6 +415,7 @@ mtapi_boolean_t embb_mtapi_scheduler_wait_for_task(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_duration_set_milliseconds
(
&
wait_duration
,
(
unsigned
long
long
)
timeout
);
embb_time_now
(
&
start_time
);
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
...
...
@@ -431,6 +433,12 @@ mtapi_boolean_t embb_mtapi_scheduler_wait_for_task(
if
(
MTAPI_INFINITE
<
timeout
)
{
embb_time_t
current_time
;
embb_time_now
(
&
current_time
);
if
(
embb_time_compare
(
&
current_time
,
&
start_time
)
<
0
)
{
/* time has moved backwards, maybe a wraparound or jitter
move end_time backward to avoid endeless loop */
start_time
=
current_time
;
embb_time_in
(
&
end_time
,
&
wait_duration
);
}
if
(
embb_time_compare
(
&
current_time
,
&
end_time
)
>
0
)
{
/* timeout! */
return
MTAPI_FALSE
;
...
...
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