Linux user-space process of the creation and management principles involved and many UNIX? in common, but there are some specific to Linux's uniqueness.
In this article, understanding the lifecycle of Linux process, explore the user process creation, memory management, dispatch and destruction of kernel internals. Linux is a dynamic system that can adapt to changing computing needs. Linux computing performance is to process a common abstract-centric. Processes can be short-term (from the command line execution of a command) or long-term (network service). Therefore, the process of scheduling for the General management becomes extremely important. The process in user space, is determined by the process identifier (PID). From the user's perspective, a PID is a numeric value, you can only identify a process. A PID of the process during the whole life does not change, but the process PID can be re-used after destruction, to cache them and not always ideal. In user space, create the process can take several forms. You can execute a program (which can lead to the creation of a new process), or within a program, called a fork or the exec system call. Fork calls will result in the creation of a child process, and exec calls will be replaced with a new program to the current process context. Next, I will discuss some methods so that you can understand how they work. In this article, I will follow the following sequence describes the process of expanded, first display process kernel represents and how they are managed in the kernel, and then look at the process of creating and dispatching of various ways (in one or multiple processors), and finally describes the process of destruction. Process means that the Linux kernel, the process is quite a structure called the task_struct. This structure contains all said this process the necessary data, in addition, also contains a lot of other data used to statistics (accounting) and maintain relationships with other process (parent and child). Introduction to the complete task_struct is beyond the scope of this article, listing 1 shows a small portion of the task_struct. This code contains this article to explore these specific elements. Task_struct located./linux/include/linux/sched.? Nbsp; manifest a small part of 1.task_struct structtask_struct {volatilelongstate; void * stack; unsignedintflags; intprio, static_prio; structlist_headtasks; structmm_struct * mm, * pid_ttgid pid_tpid active_mm;;; structtask_struct * real_parent; charcomm [TASK_COMM_LEN]; structthread_structthread; structfiles_struct * files; ...}; In Listing 1, you can see a few expected item, such as the implementation of the State, stack, a set of flags, the parent process, executing thread (there are many), and open the file. I will be a detailed description, here is simple. State variable is a number indicating the task status bit. The most common States are: TASK_RUNNING indicates that the process is running, or in the run queue was about to run; TASK_INTERRUPTIBLE said process is sleep, Hibernate TASK_UNINTERRUPTIBLE represents the process but cannot wake up; TASK_STOPPED represents the process stops and so on. For a complete list of these flags can be found in the./linux/include/linux/sched.h. Flags defined a lot of indicator, which indicates that if a process is created (PF_STARTING) or exit (PF_EXITING), or the process is currently allocated memory (PF_MEMALLOC). The executable name (without path) occupy comm (command) field. Each process will be given priority (called static_prio), but the process of actual priority is based on the load, as well as several other factors determined dynamically. The lower the priority value, the actual precedence. Tasks field provides a list of links. It contains a prev pointer (a pointer to the previous task) and a next pointer (a pointer to the next task). Process address space by mm and active_mm field represents. Mm represents the process memory descriptor, but the previous active_mm process memory descriptor (for improving context switching time of optimization). Thread_struct is used to identify the process of storage condition. This element depends on Linux is running on a specific schema, there are in-/linux/include/asm-i386/processor.h such an example. In this structure, you can find the process execution context switch storage (hardware registry, the program counter, etc.).
No comments:
Post a Comment