Does gettimeofday() on macOS use a system call?

前端 未结 2 1289
执笔经年
执笔经年 2021-02-09 13:19

I expect that gettimeofday() will call a system call to do the work of actually getting the time. However, running the following program

#include &l         


        
2条回答
  •  鱼传尺愫
    2021-02-09 13:28

    The use of dtrace instead of dtruss will clear your doubt. gettimeofday() is itself a system call. You can see this system call getting called if you run dtrace script.

    You can use following dtrace script "dtrace1.d"

    syscall:::entry
    / execname == "foo" / 
    {
    }
    

    (foo is the name of your executable)

    to run above dtrace use: dtrace -s dtrace1.d

    and then execute your program to see all system call used by your program

提交回复
热议问题