Linux kernel
文章平均质量分 84
猿来如此yXy
Liunx内核/C++进阶
展开
-
Linux Memory -- 三大allocator原理
文章目录Linux Memory -- 三大allocator原理boot memory allocatorbuddy allocatorslab allocatorLinux Memory – 三大allocator原理boot memory allocatorboot memory allocator的作用因为内核里面有很多memory struct,不可能在静态编译阶段就静态初始化...原创 2020-05-05 10:18:15 · 1100 阅读 · 0 评论 -
Linux Memory初始化过程
文章目录Linux Memory初始化过程start_kernel()setup_arch()boot memeory allocator初始化页表初始化Zone初始化以及buddy allocator初始化mem_init()kmem_cache_init()Linux Memory初始化过程start_kernel()首先我们来看看Linux的系统启动函数中的start_kernel()...原创 2020-05-03 19:58:00 · 1264 阅读 · 0 评论 -
Linux内存管理第九章 -- High Memory Management(高端内存)
文章目录Linux内存管理第九章 -- High Memory ManagementManaging the PKMap Address SpaceLinux内存管理第九章 – High Memory Managementkernel仅仅能够直接访问那些已经建立了页表项的物理内存。但是在大多数情况下,在32位机器上,用户空间和内核空间被切割为3GB/1GB,这就意味着内核最多能够直接访问的内存...原创 2020-03-26 08:32:58 · 639 阅读 · 0 评论 -
Linux内存管理第七章 -- Non-Contiguous Memory Allocation(vmalloc)
文章目录Linux内存管理第七章 -- Non-Contiguous Memory Allocation(非连续内存分配)Describing Virtual Memory Areas(描述虚拟内存区域)Linux内存管理第七章 – Non-Contiguous Memory Allocation(非连续内存分配)因为cache相关原因和内存访问延迟的原因,在处理大量内存的时候应该尽量选择连续...原创 2020-03-17 09:21:42 · 1126 阅读 · 0 评论 -
Linux内存管理第八章 -- Slab Allocator (二)
文章目录Linux内存管理 -- Slab Allocator (二)SlabsLinux内存管理 – Slab Allocator (二)Slabs本段落将描述slab如何被结构化和被管理的。用来描述slab的结构体要简单很多...原创 2020-03-08 19:51:59 · 361 阅读 · 0 评论 -
Linux内存管理第八章 -- Slab Allocator (一)
文章目录Linux内存管理 -- Slab AllocatorLinux内存管理 – Slab Allocator在本章中,来介绍内核中更加通用的分配器。Linux使用的slab allocator与用在Solaris中使用的通用分配器有许多相似之处。Linux的实现基本上是在Bonwick的the first allocator论文的基础上进行了一些改进而这些改进与他后续的论文中的描述十分相...原创 2020-03-07 17:41:08 · 2101 阅读 · 0 评论 -
Linux内存管理第六章 -- Physical Page Allocation(Buddy Allocator)
文章目录Linux内存管理 -- Physical Page AllocationManaging Free BlocksLinux内存管理 – Physical Page Allocation本章将描述在Linux中物理内存如何分配和管理。其主要算法是Binary Buddy Allocator。Buddy Allocator相比较其他分配器要快很多。这是一种将普通pow-of-two分配...原创 2020-02-25 18:14:41 · 1519 阅读 · 0 评论 -
Linux内存管理第五章 -- Boot Memory Allocator
文章目录Linux内存管理 -- Boot Memory AllocatorRepresenting the Boot MapAllocating MemoryFreeing MemoryRetiring the Boot Memory AllocatorLinux内存管理 – Boot Memory Allocator在编译阶段就初始化内核核心的memory struct是不现实的,因为有太...原创 2020-02-23 20:56:59 · 511 阅读 · 0 评论 -
Linux内存管理 -- 白话Linux page cache / swap cache/页框回收
文章目录Linux内存管理 -- 白话页框回收什么是Page Cache?什么是Swap Cache?什么是buffer Cache?Linux内存管理 – 白话页框回收经过前面几篇博客翻译和阅读Understaning Linux Virtutal Memory Manger,对于Linux页框回收有了一些基本的理解。现在自己再来对照Linux kernel2.6.9源码来做一些总结。什么...原创 2020-02-18 18:19:35 · 4154 阅读 · 1 评论 -
Linux内存管理第十一章 -- Swap Management
文章目录Linux内存管理 -- Swap ManagementDescribing the Swap AreaLinux内存管理 – Swap ManagementLinux会使用空闲的内存来缓存磁盘上的数据,然后需要再释放进程私有的或者正在使用的匿名page。这些page不像有在磁盘上对应的文件的的page那样简丹地丢弃然后再来重新读。相反必须小心滴将它们复制到磁盘介质上,有时候我们称这些...原创 2020-02-15 19:49:33 · 1368 阅读 · 0 评论 -
Linux内存管理第十章 -- 页框回收(Page Frame Reclamation)
文章目录Linux内存管理 -- 页框回收(Page Frame Reclamation)页替换策略(Page Replacement Policy)Page CachePage Cache Hash TableLinux内存管理 – 页框回收(Page Frame Reclamation)页替换策略(Page Replacement Policy)每当讨论页替换策略,提及最多的就是基于LR...原创 2020-02-14 16:56:27 · 907 阅读 · 0 评论 -
Linux内存管理第四章 -- 进程地址空间(Process Address Space)
文章目录Linux内存管理 -- 进程地址空间(Process Address Space)Linux内存管理 – 进程地址空间(Process Address Space)原创 2020-02-13 10:18:14 · 1577 阅读 · 0 评论 -
Linux内存管理第三章 -- 页表管理(Page Table Management)
Linux内存管理 – 页表管理(Page Table Management)页目录描述(Describing the Page Directory)每一个进程都有一个指针指向它自己的PGD(Page Global Directory),PGD是一个物理页框。该页框包含有一组类型为pgd_t的结构。该类型有具体的架构代码中指定。例如在x86下,其定义如下: typedef struct { ...原创 2020-02-11 18:02:09 · 5137 阅读 · 1 评论 -
Linux内存管理第二章 -- Describing Physical Memory
文章目录Linux内存管理 -- Describing Physical MemoryNodesZonesZone InitialisationInitialising mem_mapPagesLinux内存管理 – Describing Physical Memory首先来描述几个名词:NUMA:Non-Uniform Memory Access即内存非一致性访问.在很多巨星机上内存被分...原创 2020-02-10 18:12:52 · 543 阅读 · 0 评论 -
Linux Kernel 2.6.9源码分析 -- send/recieve 报文
Linux Kernel 2.6.9源码分析 – send/recieve 报文可用户socket报文读写的函数有以下几对:ssize_t read(int fd, void *buf, size_t count);ssize_t write(int fd, const void *buf, size_t count);ssize_t send(int sockfd, const ...原创 2020-01-31 18:40:47 · 457 阅读 · 0 评论 -
Linux Kernel 2.6.9源码分析 -- accept
Linux Kernel 2.6.9源码分析 – accept先来看一下原型:int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)sockfd:这个套接字用来监听一个端口,当有一个客户与服务器连接时,它使用这个一个端口号,而此时这个端口号正与这个套接字关联。当然客户不知道套接字这些细节,它只知道一个地址和一个端口号。...原创 2020-01-30 19:59:21 · 347 阅读 · 0 评论 -
Linux Kernel 2.6.9源码分析 –- connect
Linux Kernel 2.6.9源码分析 –- connect (未完待续)首先来看下connect的原型:int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);参数说明:sockfd:客户端的socket描述符addr:服务器的socket地址addrlen:socket地址的长度客户端通过...原创 2020-01-30 13:14:35 · 360 阅读 · 0 评论 -
Linux Kernel 2.6.9源码分析 -- listen
Linux Kernel 2.6.9源码分析 – listen先来看下listen的原型:int listen(int sockfd, int backlog);参数说明:sockfd:要监听的socket描述字backlog:为相应socket可以排队的最大连接个数返回值:返回错误码对于有链接的socket对子,如何来系统如何来区分谁是server,谁是client呢 ?只要在创建s...原创 2020-01-30 12:07:13 · 264 阅读 · 0 评论 -
Linux Kernel 2.6.9源码分析 -- bind
Linux Kernel 2.6.9源码分析 – bind先来看下bind API的原型:int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);参数说明:sockfd:即socket描述字,它是通过socket()函数创建了,唯一标识一个socket。bind()函数就是将给这个描述字绑定一个名字。add...原创 2020-01-30 09:31:38 · 248 阅读 · 0 评论 -
Linux Kernel 2.6.9源码分析 -- socket
Linux Kernel 2.6.9源码分析 – socket首先来看socket API的原型:int socket(int protofamily, int type, int protocol)参数说明:int protofamily:即协议域,又称为协议族(family)。常用的协议族有,AF_INET(IPV4)、AF_INET6(IPV6)、AF_LOCAL(或称AF_UNIX...原创 2020-01-29 14:31:28 · 412 阅读 · 0 评论 -
Linux 2.6.9内核实现的select,poll,eventpoll优缺点比较
Linux 2.6.9内核实现的select,poll,eventpoll优缺点比较通过前面三个博客可以得知select,poll,eventpoll 的详细实现,现在来总结对比下它们之间的不同:select 流程图poll 流程图eventpoll 流程图优缺点总结<1> 监控文件最大数不同:select和poll都是以数组形式传入药监控的文件句柄,而这个数组是有...原创 2020-01-28 18:00:46 · 727 阅读 · 0 评论 -
Linux Kernel2.6.9内核源码分析--poll
Linux Kernel2.6.9内核源码分析–polllong sys_poll(struct pollfd __user * ufds, unsigned int nfds, long timeout)poll对应的系统调用为sys_poll,以下是参数说明:struct pollfd __user * ufds:为struct pollfd的数组,里面有文件描述符,event 和rev...原创 2020-01-28 13:42:06 · 233 阅读 · 0 评论 -
Linux Kernel2.6.9内核源码分析--select
Linux Kernel2.6.9内核源码分析–select需要解决的问题:通过追踪内核源码,查看内核是如何实现select监听的功能首先来看下select API的定义和参数:int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);参数说明:...原创 2020-01-28 12:36:32 · 391 阅读 · 0 评论 -
Linux2.6.9内核源码分析--eventpoll
Linux2.6.9内核源码分析–eventpolleventpollepoll分为三个系统调用:long sys_epoll_create(int size);long sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event);long sys_epoll_wait(int epfd, struc...原创 2020-01-27 17:57:49 · 1306 阅读 · 0 评论