Linux Kernel source Code Analysis-process management and scheduling
http://wenku.baidu.com/link?url=yzMjiwX-ZzlnYZgb8CKG5veDdv6_uTbweFpb0_ lpddf7xyilf4fimm4qcl5-0gsk6snu9krfuqvrzydbl0wlu8rhgilvfms_mpil0hrsb4m
Tasks for Process Management
. Allow a process to replicate itself (actually make a multiple process of application)
. Determine which process will have the CPU
. Accept interrupts and redirect interrupts to the corresponding kernel subsystem
. Send a signal to a user process
. Managing Clock Hardware
. When a process ends, release its resources
. dynamic load Execution Module
dependencies between process modules and other modules
. Provides a simple set of system call interfaces to a user process
Provides rich interface functionality for other modules of the kernel
Memory management module, when a process is scheduled, create a memory map for it.
All other modules are dependent on the process scheduling module because they require the CPU to suspend the user process for hardware access and switch to System State for processing.
Process Creation (FORK, Copy-on-write)
In Linux, the process is created by copying a process that already exists.
At the start of the Linux kernel, the Start_kernel () initializes each system data structure, while generating a system-wide background process: init.
The init process produces several kernel subprocess by copying itself. These processes can then generate their child processes through system call fork (), and of course the raw data for these subprocess are copies of their father. The termination of a process is implemented through system call _exit ().
Termination of the process
To release the appropriate resources at the end of the process, and implement (explicit or implicit) with the exit () call
. The EXIT () implementation called Do_exit () to complete the following work
Task_struct the flag member is set to: pf_exiting
Call __EXIT_MM ()
Call Sem__exit ()
Call __exit_files (), __exit_fs (), Exit__name__space, Exit_sighand
Exit code Replace with the code provided by exit ()
Call Exit_notify () to signal to the parent process (labeled Zoombie)
Call Shedule Switch to another process
Thread implementation
Linux does not have a real thread.
is simply a mechanism for the direct sharing of resources between processes.
Kernel thread: A standard process that runs independently in the kernel.
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