Like title suggest: how can I make a call to sleep()?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You can use get_random_bytes(), similar calls to sleep() also exist for example msleep(), usleep() etc. depending on what you want to do. Note that *sleep() cannot be used in an atomic context, you will want to use *delay(). Generally you need to think twice before using sleep()/delay() calls in the kernel.
If you are writing a device driver and you want to ensure that the device has finished doing whatever (assuming you can’t use an interrupt for that and you need to poll some register or so) then instead of doing msleep(10) consider having a loop going around 5 times with an msleep(2) or similar, poll the register and break out as early as possible. The time you wait is at least the time you’ve requested and depends on system load.