Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Matthieu Dorier
codes
Commits
19816c06
Commit
19816c06
authored
Jan 08, 2015
by
Jonathan Jenkins
Browse files
hedge against precision loss in codes_local_latency
parent
4d0cd090
Changes
1
Hide whitespace changes
Inline
Side-by-side
codes/codes.h
View file @
19816c06
...
...
@@ -30,18 +30,25 @@ static inline tw_event * codes_event_new(
/* Modeled latency for communication between local software components and
* communication between daemons and hardware devices. Measured in
* nanoseconds.
* Modified Jul 7: We want to make sure that the event time stamp generated
is always greater than the default g_tw_lookahead value. Multiplying by 1.1
ensures that if tw_rand_exponential generates a zero time-stamped event, we
still have a timestamp that is greater than g_tw_lookahead.
*/
#define CODES_MEAN_LOCAL_LATENCY 0.01
#define CODES_MIN_LATENCY 0.5
#define CODES_MAX_LATENCY 1.0
#define CODES_LATENCY_RANGE \
(CODES_MAX_LATENCY-CODES_MIN_LATENCY)
static
inline
tw_stime
codes_local_latency
(
tw_lp
*
lp
)
{
int
r
=
g_tw_nRNG_per_lp
-
1
;
tw_stime
tmp
;
tmp
=
(
1
.
1
*
g_tw_lookahead
)
+
tw_rand_exponential
(
&
lp
->
rng
[
r
],
CODES_MEAN_LOCAL_LATENCY
);
tmp
=
g_tw_lookahead
+
CODES_MIN_LATENCY
*
tw_rand_unif
(
&
lp
->
rng
[
r
])
*
CODES_LATENCY_RANGE
;
if
(
g_tw_synchronization_protocol
==
CONSERVATIVE
&&
(
tw_now
(
lp
)
+
g_tw_lookahead
)
>=
(
tw_now
(
lp
)
+
tmp
))
tw_error
(
TW_LOC
,
"codes_local_latency produced a precision loss "
"sufficient to fail lookahead check (conservative mode) - "
"increase CODES_MIN_LATENCY/CODES_MAX_LATENCY)
\n
"
);
return
(
tmp
);
}
...
...
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