Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read pcap files with nanosec precision, set nano_sleep as default sle… #3

Merged
merged 1 commit into from
May 2, 2023

Conversation

plangarbalint
Copy link
Owner

No description provided.

@plangarbalint plangarbalint force-pushed the read_pcap_with_nanosec branch 2 times, most recently from e5d3ebe to 52a6830 Compare April 23, 2023 14:34
src/sleep.h Outdated
break;
}
get_current_time(now);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit concerned about this one. Converting nanosleep to a busy loop might consume many resources. Am I miss something?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it is a good idea to use absolute sleep instead of relative sleep when an application needs to be suspended and activated in a periodic time, precise periodic activation cannot be achieved with a relative sleep() or nanosleep() function call. --> https://linux.die.net/man/3/clock_nanosleep

Do you think this solution is less efficient in ensuring precise periodic suspension and activation?

In case of nanosleep we do the following.

  1. calculate now
  2. calculate nap time (from pcap file)
  3. nanosleep(nap)

When CPU time is taken away from the process right after (2) before (3) then the application will not be activated exactly at now+nap. It will be activated at now+context_switch+nap

With busy loop it is easier to eliminate the effect of context switch since the time until the program should do nothing useful is an absolute time. What is your view on this?

@plangarbalint plangarbalint force-pushed the read_pcap_with_nanosec branch from 52a6830 to 80885b0 Compare April 25, 2023 22:23
@plangarbalint plangarbalint force-pushed the read_pcap_with_nanosec branch from 80885b0 to 00e9f83 Compare May 1, 2023 07:29
@plangarbalint plangarbalint merged commit ea08502 into master May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants