Re: What is timo from sleep(9) functions
- In reply to: Farhan Khan: "What is timo from sleep(9) functions"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 05 May 2022 14:38:21 UTC
On Thu, May 5, 2022 at 7:50 AM Farhan Khan <farhan@farhan.codes> wrote: > Hi all, > > Hopefully simple question: > > What is the unit of the `int timeo` parameter in sleep(9)? Is it the > timeout in milliseconds? Or would 1 mean a second? > Related, what does the `hz` variable mean and why is it used? I see > instances of timo's in multiples of hz (ie, hz * 10). OpenGrok shows it > defined in a few different places and its not clear to me which it is. > The units are ticks. 1/hz seconds. There's other functions that let you sleep with other units (all the _sbt ones). The parameter timo specifies a timeout for the sleep. If timo is not 0, then the thread will sleep for at most timo / hz seconds. If the timeout expires, then the sleep function will return EWOULDBLOCK. Warner