0.11 Way (vi): Create process 1

Source: Internet
Author: User

Process 0 The first thing to do is to call the fork function as the parent process to create the first child process-process 1.

The kernel uses Last_pid to store the number of processes that the system has accumulated since it was powered on, and this variable is used as the process number for the new process. Btw,linux 0.11 task[64] has only 64 items and can run up to 64 processes at a time. A very important function in the fork function is called the copy_process () function.
Process 0 relies on it to complete the creation of Process 1:
1) Create task_struct for process 1, copy the contents of process 0 task_struct to process 1
2) Personalize the Task_struct and TSS for process 1
3) Create the first page table for process 1 and assign the page table entry contents of process 0 to this page table
4) Process 1 file sharing process 0
5) Set the GDT entry for process 1
6) Finally, Process 1 is set to the ready state so that it can participate in the rotation between processes.

Within Copy_process, there is an important function get_free_page (), which requests a free page in main memory and zeros the requested page for the task_struct and kernel stacks of process 1.

After completing the TASK_STRUCT setup for Process 1, the next step--
Set up paging management for process 1. Each process is loaded with its own code, data. The code and the data are addressed in the form of segments plus offsets, which are represented as logical addresses. The CPU hardware automatically calculates the logical address as a linear address that is addressable by the CPU, and then automatically translates the linear address into the physical address of the paging according to the operating system's settings on the page Catalog table and page table.

Linear address (32-bit) = Page Directory entry (10-bit) + Page table entry (10-bit) + in-page offset (12-bit)

CR3 is the page directory base register, which holds the physical address of the page catalog table, the page catalog table is always placed on the memory boundary in 4 K bytes, so the low 12 bits of its address are always 0, it does not work, even if the content is written, it will not be ignored.

0.11 Way (vi): Create process 1

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.