1.current的应用
current 指针指向当前在运行的进程,内核代码可以通过使用 current 来使用进程特定的信息。指向 task_struct 的current指针在内核堆栈内,是一个全局项。
定义:/arch/x86/include/asm/current.h #define current get_current()
应用目的:查看当前谁在使用内核你关心的那段代码的时候。
应用方法:
printk(KERN_INFO "The cuurent process commond : \"%s\" the pid :%i\n", current->comm, current->pid);
comm:当前进程执行的程序文件名,pid:当前进程的pid号。