How does the gettimeofday syscall wor‍k?

后端 未结 2 1331
[愿得一人]
[愿得一人] 2020-12-06 05:35

gettimeofday is a syscall of x86-86 according to this page(just search gettimeofday in the box):

int gettimeofday(struct timeval *t         


        
2条回答
  •  我在风中等你
    2020-12-06 06:25

    Syscalls generally create a lot of overhead, and given the abundance of gettimeofday() calls, one would prefer not to use a syscall. To that end, Linux kernel may map one or two special areas into each program, called vdso and vsyscall. Your implementation of gettimeofday() seems to be using vsyscall:

    mov $0xffffffffff600000,%rax

    This is the standard address of vsyscall map. Try cat /proc/self/maps to see that mapping. The idea behind vsyscall is that kernel provides fast user-space implementations of some functions, and libc just calls them.

    Read this nice article for more details.

提交回复
热议问题