2019-2020-1 20199301 "Linux kernel principle and Analysis" in the seventh week of work

Chapter Six

Create a process description and process

Study Notes

1. The operating system of the three major management functions:

  • Process Management
  • Memory Management
  • File system

2. The core functions of the operating system is process management.

3. To manage the construction process, the kernel to describe the process, has become a process descriptor, the process descriptor provides all the information related to the process.

  • task_struct data structure is very large

4. ready state and the operating mode are T ASK_RUNNING

5. Operating System in the process has ready state, running state, blocking state these three basic states, the actual process of the Linux kernel and the management of different state

  • Linux kernel to run it depends on whether there is no gain control of the CPU
  • A process running while waiting for a specific event or resource enters the blocking state.
  • Blocking state into two TASK_INTERRUPTIBLE (and may be wake_up signal () wake-up) and the TASK_UNINTERRUPTIBLE (only be wake_up () wake-up).

6. The process identifier PID is also important, in the process described by pid and tgid identification process.

7.struct list_head tasks for doubly linked list data structure management process

8. fork.vfork and clone these three system calls and kernel_thread kernel function can create a new process, and are by do_fork to the process of creating a function of different parameters just passed.

experiment

  • Delete menu, a new clone, the test.cgei overwritten.

  • In sys_clone, do_fork, dup_task_struck, copy_process, copy_thread, ret_from_fork to set a breakpoint

  • In MenuOS the fork, the fork function will find parked in the parent process

  • Continue stopped at the position of do_fork
  • Continue to follow

  • Initialized in the copy_thread

to sum up

In Linux, fork, vfork, and clone three system calls are made to create a process by calling do_fork, while the child process fork () system call generated in the system call processing is executed from ret_from_fork place. fork will produce the parent and child, the parent process, the return value is the number of sub-process of the process; the child process, the return value is zero. Therefore, the current process can be determined by the return value is the parent or child process. Fork function using the sub-process is obtained a copy of the parent process, copy it from the parent process address space of the entire process, including the process context, the process stack, memory information, open file descriptors, the control signal is set, the process priority, process group number, the current working directory, root directory, resource limits, control terminals. The child process only its unique process ID, such as resource use and timers. As can be seen, the cost of using the fork function is great, it copied the code segment of the parent process, data and stack segments where most of the content, making the fork function execution speed is not fast.

Guess you like

Origin www.cnblogs.com/lsqz/p/11743171.html