Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Packetdrill_tarr_ext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefan Gense
Packetdrill_tarr_ext
Commits
3eabfc17
Commit
3eabfc17
authored
8 years ago
by
Michael Tüxen
Browse files
Options
Downloads
Patches
Plain Diff
Improve the precision when waiting for an event.
Sponsored by: Netflix
parent
4fc95b91
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gtests/net/packetdrill/run.c
+19
-1
19 additions, 1 deletion
gtests/net/packetdrill/run.c
with
19 additions
and
1 deletion
gtests/net/packetdrill/run.c
+
19
−
1
View file @
3eabfc17
...
...
@@ -62,7 +62,11 @@
* sequence that wait_for_event() must execute while waiting
* for the next event.
*/
#if defined(__FreeBSD__)
const
int
MAX_SPIN_USECS
=
100
;
#else
const
int
MAX_SPIN_USECS
=
20
;
#endif
static
struct
state
*
state
=
NULL
;
...
...
@@ -328,7 +332,7 @@ void wait_for_event(struct state *state)
* that we know has a fine-grained usleep(), then
* usleep() instead of spinning on the CPU.
*/
#if defined(linux)
|| defined(__FreeBSD__)
#if defined(linux)
/* Since the scheduler may not wake us up precisely
* when we tell it to, sleep until just before the
* event we're waiting for and then spin.
...
...
@@ -337,6 +341,20 @@ void wait_for_event(struct state *state)
usleep
(
wait_usecs
-
MAX_SPIN_USECS
);
}
#endif
#if defined(__FreeBSD__)
/* Since the scheduler may not wake us up precisely
* when we tell it to, sleep until just before the
* event we're waiting for and then spin.
* Since FreeBSD is overshooting by about 10 percent,
* take this into account.
*/
if
(
wait_usecs
>
MAX_SPIN_USECS
)
{
useconds_t
delta
=
(
useconds_t
)(
wait_usecs
-
MAX_SPIN_USECS
);
delta
-=
delta
>>
3
;
usleep
(
delta
);
}
#endif
/* At this point we should only have a millisecond or
* two to wait, so we spin.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment