Meaning of system call
In order to interact with processes on the user space, the kernel provides a set of interfaces.
The application accesses hardware and other operating system resources through this set of interfaces.
Complete control of hardware and resource access. Safe, reliable, multi-tasking, virtual must
Abstraction of the hardware device (providing the independence of the device).
exception, sink, system call: Three ways in which user space enters kernel space
Principle
Sys_write will invoke the Write method in the corresponding struct file, operations, based on the files that the system write outputs.
Procedures for adding system calls
Take kernel 2.6.11 as an example long my_syscall (int i);
- Download Kernel 2.6 Kernel source, switch to root directory
- In/arch/i386/kernel/entry. s in Sys_call_table last added. Long My_syscall
- Add the system call number last in/include/asm-i386/unistd.h
#define __NR_my_syscall 338
The Nr_syscalls value +1
- Add the implementation of the system call in the/arch/i386/kernel/sys_i386.c file (without modifying Mkefile)
Asmlinkage long Sys_my_syscall (int i) {}
- Writing User Programs
#include<syscall.h>#include<linux/unistd.h>#define __NR_my_syscall 338_syscall1(longint, i)Int main(){ Int a = my_syscall(5);}
Linux design and implementation notes-how system calls work and the process of adding system calls