System call: How to switch the user state to the kernel state
In Linux, system calls are implemented through software interrupts in the 0x86 architecture. This software interrupt differs from the usual hardware interrupt in that it is triggered by a software instruction rather than an external device, which is an exception that can be triggered by the programmer, and calling the INT 0x80 assembly instruction can produce an exception with a vector number of 128.
The difference and connection between process and thread
The operating system textbook on the theory of what is not said, here is a copy of the Linux process and the replication thread similarities and differences.
We know that the thread implementation of Linux is done outside the core, and the kernel provides the interface do_fork () to create the process. The kernel provides two system calls, __clone () and fork (), and eventually calls the Do_fork () kernel API with different parameters. Of course, to implement threads, there is no core support for shared data segments for multi-process (in fact, lightweight processes), so Do_fork () provides a number of parameters, including CLONE_VM (shared memory space), CLONE_FS (shared file system information), Clone_ Files (shared file descriptor tables), Clone_sighand (Shared signal handle table), and clone_pid (shared process ID, only valid for in-process, that is, process No. 0). when using the fork system call, the kernel calls Do_fork () without using any shared properties, and the process has a separate running environment. When you use Pthread_create () to create a thread, all of these properties are eventually set to call __clone (), and all of these parameters are passed to the Do_fork () in the kernel, thus creating a "process" that has a shared run environment, and only the stack is independent, by __clone ( Incoming
Linux User state and kernel state