[Principles and implementation of Windows Kernel] Reading Notes (6)

Source: Internet
Author: User

In the Windows Kernel, the execution layer is responsible for various management and policy-related functions, while the kernel layer (or microkernel) implements the core mechanism of the operating system.

Processes and thread objects at the kernel layer

The data structures in the kernel layer midline and process are kprocess and kthread. Kprocess is defined:

Typedef struct _ kprocess {// these two headers rarely use dispatcher_header header; // when the process participates in Performance Analysis (profiling, add a node to the global performance analysis process list (kiprofilelisthead) list_entry profilelisthead; // fields used during context switching // The first entry points to the page Directory table address of the Process // The second entry points to the super space of the process (hyper space) page Directory address ulong_ptr directorytablebase [2]; # If defined (_ x86 _) // LDT descriptor kgdtentry ldtdescriptor; // DOS-compatible Program , Allows the use of int 21h to call the DOS system function kidtentry int21descriptor; // I/O permission table, I/O privilege map ushort iopmoffset; // iopm can control the process's user mode I/O access permissions; The iopl domain defines the process's I/O priority uchar iopl; Boolean unused; # endif # If defined (_ amd64 _) ushort iopmoffset; # endif // the current process records the processors on which the current process is running volatile kaffinity activeprocessors; // when the clock is interrupted, the following two fields will be referenced, recording the time spent in user mode and kernel mode. ulong kerneltime will be updated only when the thread ends; ulong usertime; // The following two fields are rarely referenced. // The linked list records that the process is in the ready state but not added to the global ready list. Thread list_entry readylisthead; // when the process is to be swapped out of the memory, it is added to the kiprocessoutswaplisthead through this domain. // when the process is to be swapped in the memory, add this field to single_list_entry swaplistentry in kiprocessinswaplisthead; # If defined (_ x86 _) // point to the function used to process Ctrl + C interruptions, only for vdm (Virtual DOS machine) run the 16-bit program in the environment. Pvoid vdmtrapchandler; # elsepvoid reserved1; # endif // This linked list contains all the current processes of the Process list_entry threadlisthead; // The spin lock object that protects the data member kspin_lock processlock; // specifies the processors on which the thread of the process can run. each bit of the binary value corresponds to a processor (CORE) kaffinity affinity of the current computer; // The bit defined next must be consistent with the subsequent bit field // These bits can only be written using the interlock operation # define defaults 0 # define kprocess_disable_boost_bit 1 # define kprocess_disable_quantum_bit 2 {Union struct {long autoalignment: 1; long dis Ableboost: 1; long disablequantum: 1; long reservedflags: 29 ;}; long processflags ;}; // specify the basic priority of the thread in the process schar basepriority; // quantumreset specifies the basic Time Limit reset value of the thread in a process schar quantumreset; // specifies whether the process is in the memory uchar state; // select the appropriate ideal processor uchar threadseed for the thread of the process; // records the power status of uchar powerstate; // select uchar idealnode for a process; // Boolean visited; Union {kexecute_options flags are not used in wrk; // set the memory execution option for a process. In order to support NX (no-execute, the memory cannot be executed) uchar execut Eoptions ;};# if! Defined (_ x86 _)&&! Defined (_ amd64 _) palignment_exception_table alignmentexceptiontable; # endif // records the number of threads in the current process in the memory ulong_ptr stackcount; // concatenates all processes with active threads in the current system into a linked list list_entry processlistentry;} kprocess, * pkprocess, * prkprocess;

Each process corresponds to a kprocess object. Kprocess mainly records two types of information: one is related to the memory environment of the process, and the other is some attributes related to the thread.

In the kthread structure, many domains are related to the thread scheduling mechanism:

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.