0.11 Way (v): activation process 0

Source: Internet
Author: User

The first process of Linux-process 0.
Linux 0.11 is a modern operating system that supports multiple processes, so we need the support of process management information data structure: task_struct, task[64], GDT, etc.

We need to set the distribution of physical memory: main memory area, buffer and virtual disk.

memory_end--system effective Memory End position
main_memory_start--main memory Area start position
buffer_memory_end--Buffer End Position
Main_memory_start = buffer_memory_end--buffer followed by main memory
If you want to set a virtual disk, place it between the buffer and the main memory

Within 1MB is the kernel code and the memory space where most of the data controlled by the kernel is not allowed to be accessed by the user process. More than 1MB, especially the main memory area is mainly the user process code, the data is in the space, so the use of dedicated to manage user process paging management mechanism. This part of the work is done by the Mem_init () function.

Next, execute the Trap_init () function to hook up the interrupt and exception handling service to IDT and gradually rebuild the interrupt service system.

To communicate with a block device, a process must pass through a buffer in the host's memory, which is controlled by a request item, which determines which logical block of the device is currently being processed based on the records in the request item.

Next, set up the serial port, monitor, and keyboard, and start the boot time.

Tss_struct and task_struct are important data structures for a process, which holds information about various registers, including process priorities, user groups, TSS, LDT, and other basic operational information.

We initialize process 0 with the Sched_init () function, set the clock interrupt, set the total system call entry (System_call), initialize the buffer management structure, initialize the hard disk and floppy disk, and then turn on the interrupt.

The final step is to flip process 0 from 0 privilege level to 3 privilege level through Move_to_user_mode (). The CPU execution Iret instruction automatically restores the values in the stack to the 5 registers of SS, ESP, EFlags, CS, EIP. The system_call corresponding int 0x80 interrupt flips the 3 privilege level to the 0 privilege level, and Iret flips the 0 privilege level back to the 3 privilege level, so Move_to_user_mode () takes advantage of this feature of Iret to successfully flip process 0 's 0 privilege level to 3 privilege level.

0.11 Way (v): activation process 0

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.