ImageVerifierCode 换一换
格式:DOCX , 页数:36 ,大小:1.16MB ,
资源ID:22598069      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22598069.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(操作系统内核知识汇总英文版文档格式.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

操作系统内核知识汇总英文版文档格式.docx

1、 even if you miss some details you can get the gist of whats happening. The main obstacle is the lack of context around some of the code, such as when or why it runs or the underlying features of the machine. I hope to provide a bit of that context. Due to brevity (hah!) a lot of fun stuff like inte

2、rrupts and memory gets only a nod for now. The post ends with the highlights for the Windows boot.At this point in the Intel x86 boot story the processor is running in real-mode, is able to address 1 MB of memory, and RAM looks like this for a modern Linux system:RAM contents after boot loader is do

3、neThe kernel image has been loaded to memory by the boot loader using the BIOS disk I/O services. This image is an exact copy of the file in your hard drive that contains the kernel, e.g./boot/vmlinuz-2.6.22-14-server. The image is split into two pieces: a small part containing the real-mode kernel

4、code is loaded below the 640K barrier; the bulk of the kernel, which runs in protected mode, is loaded after the first megabyte of memory.The action starts in the real-mode kernel header pictured above. This region of memory is used to implement theLinux boot protocolbetween the boot loader and the

5、kernel. Some of the values there are read by the boot loader while doing its work. These include amenities such as a human-readable string containing the kernel version, but also crucial information like the size of the real-mode kernel piece. The boot loader alsowritesvalues to this region, such as

6、 the memory address for the command-line parameters given by the user in the boot menu. Once the boot loader is finished it has filled in all of the parameters required by the kernel header. Its then time to jump into the kernel entry point. The diagram below shows the code sequence for the kernel i

7、nitialization, along with source directories, files, and line numbers:Architecture-specific Linux Kernel InitializationThe early kernel start-up for the Intel architecture is in filearch/x86/boot/header.S. Its in assembly language, which is rare for the kernel at large but common for boot code. The

8、start of this file actually contains boot sector code, a left over from the days when Linux could work without a boot loader. Nowadays this boot sector, if executed, only prints a “bugger_off_msg” to the user and reboots. Modern boot loaders ignore this legacy code. After the boot sector code we hav

9、e the first 15 bytes of the real-mode kernel header; these two pieces together add up to 512 bytes, the size of a typical disk sector on Intel hardware.After these 512 bytes, at offset 0200, we find the very first instruction that runs as part of the Linux kernel: the real-mode entry point. Its inhe

10、ader.S:110and it is a 2-byte jump written directly in machine code as 0x3aeb. You can verify this by running hexdump on your kernel image and seeing the bytes at that offset just a sanity check to make sure its not all a dream. The boot loader jumps into this location when it is finished, which in t

11、urn jumps to229where we have a regular assembly routine called start_of_setup. This short routine sets up a stack, zeroes thebsssegment (the area that contains static variables, so they start with zero values) for the real-mode kernel and then jumps to good old C code atarch/x86/boot/main.c:122.main

12、() does some house keeping like detecting memory layout, setting a video mode, etc. It then callsgo_to_protected_mode(). Before the CPU can be set to protected mode, however, a few tasks must be done. There are two main issues: interrupts and memory. In real-mode theinterrupt vector tablefor the pro

13、cessor is always at memory address 0, whereas in protected mode the location of the interrupt vector table is stored in a CPU register called IDTR. Meanwhile, the translation of logical memory addresses (the ones programs manipulate) to linear memory addresses (a raw number from 0 to the top of the

14、memory) is different between real-mode and protected mode. Protected mode requires a register called GDTR to be loaded with the address of aGlobal Descriptor Tablefor memory. So go_to_protected_mode() callssetup_idt()andsetup_gdt()to install a temporary interrupt descriptor table and global descript

15、or table.Were now ready for the plunge into protected mode, which is done byprotected_mode_jump, another assembly routine. This routine enables protected mode by setting the PE bit in the CR0 CPU register. At this point were running withpagingdisabled; paging is an optional feature of the processor,

16、 even in protected mode, and theres no need for it yet. Whats important is that were no longer confined to the 640K barrier and can now address up to 4GB of RAM. The routine then calls the 32-bit kernel entry point, which isstartup_32for compressed kernels. This routine does some basic register init

17、ializations and callsdecompress_kernel(), a C function to do the actual decompression.decompress_kernel() prints the familiar “Decompressing Linux” message. Decompression happens in-place and once its finished the uncompressed kernel image has overwritten the compressed one pictured in the first dia

18、gram. Hence the uncompressed contents also start at 1MB. decompress_kernel() then prints “done.” and the comforting “Booting the kernel.” By “Booting” it means a jump to the final entry point in this whole story, given to Linus by God himself atopMountain Halti, which is the protected-mode kernel en

19、try point at the start of the second megabyte of RAM (0100000). That sacred location contains a routine called, uh,startup_32. Butthisone is in a different directory, you see.The second incarnation of startup_32 is also an assembly routine, but it contains 32-bit mode initializations. It clears the

20、bss segment for the protected-mode kernel (which is thetruekernel that will now run until the machine reboots or shuts down), sets up the final global descriptor table for memory, builds page tables so that paging can be turned on, enables paging, initializes a stack, creates the final interrupt des

21、criptor table, and finally jumps to to the architecture-independent kernel start-up,start_kernel(). The diagram below shows the code flow for the last leg of the boot:Architecture-independent Linux Kernel Initializationstart_kernel() looks more like typical kernel code, which is nearly all C and mac

22、hine independent. The function is a long list of calls to initializations of the various kernel subsystems and data structures. These include the scheduler, memory zones, time keeping, and so on. start_kernel() then callsrest_init(), at which point things are almost all working. rest_init() creates

23、a kernel thread passing another function,kernel_init(), as the entry point. rest_init() then callsschedule()to kickstart task scheduling and goes to sleep by callingcpu_idle(), which is the idle thread for the Linux kernel. cpu_idle() runs forever and so does process zero, which hosts it. Whenever t

24、here is work to do a runnable process process zero gets booted out of the CPU, only to return when no runnable processes are available.But heres the kicker for us. This idle loop is the end of the long thread we followed since boot, its the final descendent of the very firstjumpexecuted by the proce

25、ssor after power up. All of this mess, from reset vector to BIOS to MBR to boot loader to real-mode kernel to protected-mode kernel, all of it leads right here, jump by jump by jump it ends in the idle loop for the boot processor, cpu_idle(). Which is really kind of cool. However, this cant be the w

26、hole story otherwise the computer would do no work.At this point, the kernel thread started previously is ready to kick in, displacing process 0 and its idle thread. And so it does, at which point kernel_init() starts running since it was given as the thread entry point.kernel_init()is responsible f

27、or initializing the remaining CPUs in the system, which have been halted since boot. All of the code weve seen so far has been executed in a single CPU, called the boot processor. As the other CPUs, called application processors, are started they come up in real-mode and must run through several ini

28、tializations as well. Many of the code paths are common, as you can see in the code forstartup_32, but there are slight forks taken by the late-coming application processors. Finally, kernel_init() callsinit_post(), which tries to execute a user-mode process in the following order: /sbin/init, /etc/

29、init, /bin/init, and /bin/sh. If all fail, the kernel will panic. Luckily init is usually there, and starts running as PID 1. It checks its configuration file to figure out which processes to launch, which might include X11 Windows, programs for logging in on the console, network daemons, and so on.

30、 Thus ends the boot process as yet another Linux box starts running somewhere. May your uptime be long and untroubled.The process for Windows is similar in many ways, given the common architecture. Many of the same problems are faced and similar initializations must be done. When it comes to boot on

31、e of the biggest differences is that Windows packs all of the real-mode kernel code, and some of the initial protected mode code, into the boot loader itself (C:NTLDR). So instead of having two regions in the same kernel image, Windows uses different binary images. Plus Linux completely separates boot loader and kernel; in a way this automatic

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1