2012年3月28日

摘要: d void main(){int a;}dsdfThis is test blog 阅读全文

posted @ 2012-03-28 13:27 Teddy Yan 阅读(129) 评论(0) 推荐(0) 编辑


2012年2月24日

摘要: schedule.c 是关于进程调度的。schedule 函数是核心,先检查task列表中,有没有收到信号的,有的话处理之。/* check alarm, wake up any interruptible tasks that have got a signal */ for(p = &LAST_TASK ; p > &FIRST_TASK ; --p) if (*p) { if ((*p)->alarm && (*p)->alarm < jiffies) { (*p)->signal |= (1<<(SIGALRM- 阅读全文

posted @ 2012-02-24 11:10 Teddy Yan 阅读(757) 评论(0) 推荐(0) 编辑


2012年2月16日

摘要: Linux 系统包含了一大堆的中断,是所有操作的基础。中断中的开闭中断cli(close interrupt)指令用来复位CPU标志寄存器中的中断标志,使系统不响应外部中断。sti(start interrupt)指令用来复位,使系统响应中断。asm.s 设置了一堆底层中断,进入中断前要压入eax等寄存器,执行完要pop 出一些寄存器。这种统一的工作在 no_error_code里trap.c 里面是真正的中断处理C函数。set_trap_gate 就是设置IDT, 把asm.s中的函数地址加载到IDT表中。这个函数里内嵌汇编,内嵌汇编的语法讲了一些system_call.s 是系统调用的处理 阅读全文

posted @ 2012-02-16 16:00 Teddy Yan 阅读(380) 评论(0) 推荐(0) 编辑


2012年2月13日

摘要: bootsect.s 我们实验环境中,Image 就是一个软盘镜像,bootsect.s就在软盘的第一个扇区中(引导扇区,0磁道,0磁头,第一个扇区)硬盘有一个单独的镜像文件BIOS ROM如果设置成软盘启动,就把引导扇区的代码加载到0x7C00开始处执行。因为前面的内存保存有有用的信息。如果是从硬盘启动系统,就不执行bootsect.s。LILO, Grub等多操作系统引导程序来完成bootsect.s的任务。setup.s利用BIOS ROM中断读取硬件的系统数据,并将保存在0x90000的内存,覆盖掉bootsect.s 并将system模块(不超过512K)移动到0x00000处,加载 阅读全文

posted @ 2012-02-13 19:30 Teddy Yan 阅读(710) 评论(0) 推荐(0) 编辑

摘要: Linux 内存管理主要是32保护模式下,段页式内存管理。如何处理内存相关的寄存器,使得程序可以读写超过4G的内存。x86这个CPU框架,会根据寄存器的值和段页式规则来进行地址变换,进行内存访问。其中,也会进行权限验证等附加判断。几个概念:保护模式vs实模式保护模式下的:虚地址:程序产生的段选择符,段内偏移地址两部分组成。要经过分段地址变换处理后,才对应到屋里地址。逻辑地址:在Intel86保护模式下,就是指程序执行代码段限长内的偏移地址。线性地址:虚拟地址到物理地址变换的中间层。如果没有启用分页机制,线性地址就是物理地址。在保护模式下,读取内存很费周章。如下图,需要先找到GDT,然后找到LD 阅读全文

posted @ 2012-02-13 19:30 Teddy Yan 阅读(287) 评论(0) 推荐(0) 编辑


2012年1月30日

摘要: 先看了 Linux Kernel Development 再看了 Oreilly-Linux.Device.Drivers.3rd.Edition 后来看了Linux 0.01 内核分析与操作系统设计 然后,打算仔细研究 Linux0.11代码 1. 在Linux 4.1.1 上搭建bochs的Linux Kernel 调试环境安装bochsbochs-2.1.1.tar.gz 在需要带with-gdb-stub 编译,但是由于编译器比较新,所以必须在config.h中定义宏 #define PARANOIDLinux 0.11 编译及虚拟机linux-0.11-081030.tar.gz 这 阅读全文

posted @ 2012-01-30 13:16 Teddy Yan 阅读(6933) 评论(0) 推荐(0) 编辑


2011年11月25日

摘要: 最近看了侯捷翻译的STL源码剖析,感觉有些启发。迭代器:Allocator 空间配置器,全域函数 construct(), destroy()iterator 是个智能指针,可以从原生指标提取出需要的类别。这样,容器需要实现自己迭代器。容器RB tree的在STL的使用还是很广泛的,不仅是map,set也是用的RB tree根据Vector的特点,迭代器就是使用的原生指针,作为迭代器的指针使用List的迭代器不是原生指针,因为++实际上不是地址的++,而是取得next指针。list遍历的代码,注意拼写 list<int>::iterator ite; for(ite = ilist 阅读全文

posted @ 2011-11-25 15:42 Teddy Yan 阅读(331) 评论(0) 推荐(0) 编辑


2011年6月16日

摘要: The Block I/O Layer The smallest addressable unit on a block device is a sector. Sectors come in various powers of two, but 512 bytes is the most common size. although many block devices can operate on multiple sectors at one time. Software has different goals and therefore imposes its own smalles.. 阅读全文

posted @ 2011-06-16 17:23 Teddy Yan 阅读(190) 评论(0) 推荐(0) 编辑

摘要: The Memory Descriptor Processes may elect to share their address spaces with their children by means of the CLONE_VM flag to clone().The process is then called a thread. Recall from Chapter 3, “Process Management,” that this is essentially the only difference between normal processes and so-called . 阅读全文

posted @ 2011-06-16 17:23 Teddy Yan 阅读(155) 评论(0) 推荐(0) 编辑

摘要: The Page Cache and Page Writeback In this manner, the page cache contains chunks of recently accessed files. During a page I/O operation, such as read(),2 the kernel checks whether the data resides in the page cache. If the data is in the page cache, the kernel can quickly return the requested p... 阅读全文

posted @ 2011-06-16 17:23 Teddy Yan 阅读(145) 评论(0) 推荐(0) 编辑


Copyright © 2024 Teddy Yan
Powered by .NET 8.0 on Kubernetes