Linux User state and kernel state

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.