linux sleeping with clock_nanosleep

前端 未结 4 1037
自闭症患者
自闭症患者 2021-02-09 13:10

I want to use clock_nanosleep for waiting of 1 microsec.. As far as I understand, I have to give an absolute time as input. Is the following code okay in this case?

<         


        
4条回答
  •  我在风中等你
    2021-02-09 13:44

    As far as I understand, I have to give an absolute time as input.

    No, the flags argument allows you to choose relative or absolute time. You want

    clock_nanosleep(CLOCK_REALTIME, 0, &deadline, NULL);
    

    to specify one microsecond from now.

提交回复
热议问题