Ulk---Chap3 processes:process descriptor handling

Source: Internet
Author: User

Processes is dynamic entities whose lifetimes range from a few milliseconds to months. Thus, the

Kernel must is able to handle many processes at the same time, and process descriptors is stored

In dynamic memory rather than in the memory area permanently assigned to the kernel. For each

Process, Linux packs, different data structures in a single per-process memoryArea: a small data

Structure linked to the process descriptor, namely the Thread_info structure, and the Kernel mode 5 >

Process stack. The length of this memory area is usually 8192 bytes (both page frames). For reasons

of efficiency the kernel stores the 8-KB memory area in both consecutive page frames with the first

Page frame aligned to a multiple of 8KB; This could turn out to be a problem when little dynamic memory

is available, because the free memory may become highly fragmented. Therefore, in the 80x86 architecture

The kernel can configured at compilation time so, the memory area including stack and Thread_info

Structure spans a single page frame (4096 bytes).

In the section ' Segmentation in Linux ' in Chapter 2, we learned that a process in Kernel Mode accesses

A stack contained in the kernel data segment, which are different from the stack used by the process in User

Mode. Because kernel control paths make little use of the stack, only a few thousands bytes of kernel

Stack is required. Therefore, 8KB is ample space for the stack and the therad_info structure. However,

When stack and thread_info structure is contained in a single page frame, the kernel uses a few additional

Stacks to avoid the overflows caused by deeply nested intertupts and exceptions.

Fig 3-2 in textbook shows how the data structures is stored in the 2-page (8KB) memory area. The

Thread_info structure resides at the beginning of the memory area, and the stacks grows downward from

The end. The figure also shows, the thread_info structure and the TASK_STRUCT structure are mutually

Linked by means of the fields Taks and Thrad_info, repectively.

The ESP register is the CPU stack pointer, which are used to address the stack's top location. On 80x86

Systems, the stack starts at the end and grows toward the beginning of the memory area. Right after

Switching from User mode to Kernel Mode, the Kernel stack of a process are always empty, and therefore

The ESP register points to the byte immediately following the stack.

The value of the ESP register is decreased as soon as data are written into the stack.

Ulk---Chap3 processes:process descriptor handling

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.