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 441789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:00:26+00:00 2026-05-12T21:00:26+00:00

I am just interested how sleep(time in ms) is implemented in a C library

  • 0

I am just interested how sleep(time in ms) is implemented in a C library or basically at the OS level…

I am guessing…

  1. May be the based on the processor speed you do a while loop of nop’s (I am not sure if the sleep time will be accurate)…
  2. Any special register in processor, where you write some value and the processor simply halts for specified time (this would be very inefficient as the processor can’t run even other programs).

Any clues? Probably C library source code can explain? I am not too particular about how “C” is implementing it… I am just wondering in general how the “sleep()” function is implemented.

  • 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-05-12T21:00:27+00:00Added an answer on May 12, 2026 at 9:00 pm

    Sleep() is implemented at the OS level. The processor doesn’t spin when a task/thread/process is sleeping. That particular thread is put on a pending queue (the thread isn’t ready to run) until the time has expired at which point the thread will be placed on the ready to run queue.

    In the meantime, other threads that are ready to run will be run.

    Only if no threads are ready to run will the OS go into the idle thread, which in generally issues instructions to shutdown (or put into a low-power state anyway) the processor until an hardware interrupt occurs.

    Only for a very simple system (like the most simple of embedded systems), might Sleep() actually be implemented as nothing more than a busy wait loop.

    Any operating system textbook, such as “Modern Operating Systems” by Tanenbaum will cover this in great detail – pretty much any of them (even an old, cheap, used one).

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

Sidebar

Related Questions

This may not be the most technical question, but I was just interested, nonetheless...
i am just interested in how these things work and am after a library
I just found Data::Section and I got interested in it. Unfortunately, I simply cannot
I have just started reading about ORMLite since I am interested in using it
I'm interested in texture streaming in DirectX but google seems unhelpful. Maybe I just
I'm not interested in call or apply to change the this reference. Just for
Just interested in knowing if there are any good (and short! :-) ) articles
I m trying to invoke a URL in C#, I am just interested in
Just interested, if anyone has any sample code, using the UIImagePicker for a cameraview
Not that I'm in that situation currently, but I'm just interested in the answer...

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.