syscall - 间接系统调用

NAME      
       syscall - 间接系统调用

SYNOPSIS      
       #define _GNU_SOURCE       
       #include <unistd.h>
       #include <sys/syscall.h>                 /* For SYS_xxx definitions */

       int syscall(int number, ...);


DESCRIPTION   
       syscall() 执行一个系统调用,根据指定的参数number和所有系统调用的汇编语言接口来确定调用哪个系统调用。
       系统调用所使用的符号常量可以在头文件<sys/syscll.h>里面找到。


EXAMPLE     

#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>

int     main(int argc, char *argv[])
{
	pid_t tid;

         tid = syscall(SYS_gettid);
	printf("%d\n",tid);
	printf("%d\n",getpid());
	return 0;
}

$ gcc main.c

$ ./a.out

3280
3280

这里是单线程的进程,此值与getpid()的值相同。

连接见:
http://www.kernel.org/doc/man-pages/online/pages/man2/syscall.2.html

 

 

你可能感兴趣的:(syscall - 间接系统调用)