Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8104525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:52:30+00:00 2026-06-05T23:52:30+00:00

I’m reading in multuple tiny files and outputing them in a single file that

  • 0

I’m reading in multuple tiny files and outputing them in a single file that is 5 seconds long. I can’t control when the input files come in, how large they are, length of time contained inside of each etc. I want to output a full file every 5 seconds with all the data in every file generated for that 5 second interval. I want this to act in a quasi-streaming manner, no buffering files and creating output 5 seconds in the future.

This in a situation like this I have to handle the case when no input file exists by sleeping and waking up to pole for new values. However, I also need to stop my sleep/polling when I hit the 5 second mark so I output my new 5 second block. Which implies I have to be doing some comparisons to a clock to know if 5 seconds have passed and I’m ready to output my results.

I’m wondering if each of these wall clock checks will become system calls to the OS with all the expense tht entails? If possible, without too much effort, I would prefer to minimize CPU calls to get the wall clock (mainly to save CPU, I’ll be doing very quick polling and the constant CPU calls for each of dozens of applications may actually burn up some CPU). What I would prefer is a system that works off of cpu cycles and only does a call to the OS on occasion to re-sync it’s internal timer. Now for this program it’s not worth going out of my way to implement anything complicated, but it made me wonder. Does the c++ language already mave any methods that do what I described, working with cpu time and syncing to wall clock intermittently, or do they always do a system call every time I try to get time?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:52:32+00:00Added an answer on June 5, 2026 at 11:52 pm

    That’s a platform-dependent question. The Linux syscall you’re talking about is gettimeofday(), and it is specifically written to have extremely low overhead. On some machines, as low as 20ns. Here’s some detail on how it’s done:

    faster equivalent of gettimeofday

    The basic trick is that not every OS service requires a context switch. In this case, Linux can provide the current time with high resolution, while staying entirely in userspace. Unless you can prove you’ve created a bottleneck, trust your C library to do the right thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.