
Linux源码解析
从一而终
这个作者很懒,什么都没留下…
展开
-
ip_frag_next没看懂的操作
struct sk_buff *ip_frag_next(struct sk_buff *skb, struct ip_frag_state *state){ /* len初始为剩余长度 */ unsigned int len = state->left; ---| struct sk_buff *skb2; | struct iphdr *iph; |? .原创 2022-01-22 19:37:07 · 1338 阅读 · 0 评论 -
Linux----barrier
首先贴一段代码吧:E:\整理分类\源码\linux-5.14.14\arch\arm64\kernel\process.c/* * Thread switching. */__notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next){ struct task_struct *last; fpsimd_thread_switch(n.原创 2021-12-26 12:37:53 · 808 阅读 · 1 评论 -
linux内核侵入式链表
// 实验:;linux内核嵌入式链表#include <iostream>#include <string>struct list_head { struct list_head* next; struct list_head *prev;};#if 0// 案例1: struct list_head StuLis放在 struct Student的首部struct Student{ struct list_head StuList; .原创 2021-12-19 21:43:52 · 496 阅读 · 0 评论 -
linux内核对原子操作的实现
/* * ARMv6 UP and SMP safe atomic ops. We use load exclusive and * store exclusive to ensure that these are atomic. We may loop * to ensure that the update happens. */#define ATOMIC_OP(op, c_op, asm_op) \static inline void arch_atomic_##op(in.原创 2021-12-07 21:15:14 · 904 阅读 · 0 评论 -
动态存储器分配伙伴系统(buddy system)2
struct free_area { struct list_head free_list[MIGRATE_TYPES]; unsigned long nr_free;};E:\整理分类\源码\linux-5.14.14\include\linux\mmzone.h原创 2021-12-06 21:59:27 · 318 阅读 · 0 评论 -
brk和sbrk
#include <unistd.h>int brk(void *addr);void *sbrk(intptr_t increment);sbrk/brk增量方式管理动态内存 申请内存是在动态内存后面申请 释放也是释放最后面 不能选择性的释放增量动态内存,只会从后往前释放 一般来说sbrk申请动态内存,brk来释放动态内存 sbrk/brk 都有申请和释放的功能...原创 2021-11-29 22:26:56 · 234 阅读 · 0 评论 -
tcmalloc性能测试
#include <sys/time.h>#include <unistd.h>#include <stdlib.h>#include <stdio.h>int main(){ struct timeval StartTime; struct timeval EndTime; double TimeUse = 0; gettimeofday(&StartTime, NULL); //测量开始 char* pTest = NUL.原创 2021-11-27 07:39:56 · 321 阅读 · 0 评论 -
进程IPC-管道pipe
pipe-> pipe函数原型:#include <unistd.h> int pipe(int file_descriptor[2]);//建立管道,该函数在数组上填上两个新的文件描述符后返回0,失败返回-1。eg.int fd[2]int result = pipe(fd);pipe->sys_pipe->-------------------------------------------E:\整理分类\源...原创 2021-11-14 21:26:19 · 979 阅读 · 0 评论 -
进程和进程调度器的关系
D:\书籍\源码\linux-5.14.4\include\linux\sched.h 661struct task_struct {#ifdef CONFIG_THREAD_INFO_IN_TASK /* * For reasons of header soup (see current_thread_info()), this * must be the first element of task_struct. */ struct thread_info threa...原创 2021-11-08 20:00:37 · 530 阅读 · 0 评论 -
linux struct sched_class
D:\书籍\源码\linux-5.14.4\kernel\sched\sched.h 2104Linux中,将调度器公共的部分抽象,使用struct sched_class结构体描述一个具体的调度类。// 抽象调度类struct sched_class {#ifdef CONFIG_UCLAMP_TASK int uclamp_enabled;#endif void (*enqueue_task) (struct rq *rq, struct task_struct *p,...原创 2021-11-08 19:09:05 · 531 阅读 · 0 评论 -
Linux进程sched类的优先级顺序
/* * The order of the sched class addresses are important, as they are * used to determine the order of the priority of each sched class in * relation to each other. */#define SCHED_DATA \ STRUCT_ALIGN(); \ __begin_sched_classes = .; \ *(...原创 2021-11-08 18:41:00 · 547 阅读 · 0 评论 -
epoll水平出发何边沿触发
LT和ET模式epoll对文件描述符的操作有2种模式: LT和ETLT Level Trigger, 电平触发 默认 只有文件描述符号上有未处理的读写事件都会通知, 只要存在着事件就会不断的触发,直到处理完成ET Edge Trigger, 边沿触发 通过EPOLLET来设置 当且仅当读写事件到来时通知, 只触发一次相同事件或者说只在从非触发到触发两个状态转换的时候儿才触发LT(level triggered)是缺省的工作方式,并且同时支持block和no...原创 2021-09-10 07:23:13 · 134 阅读 · 0 评论 -
linux5.12.2系统调用表——fork
代码68行:57 common fork sys_forkunistd32.h对#define__SYSCALL(x,y)理解:#define__NR_fork2 //偏移量__SYSCALL(__NR_fork,sys_fork)===============================================================nolibc.hstatic__attribute__((unuse...原创 2021-07-05 19:46:45 · 340 阅读 · 0 评论 -
asmlinkage的理解
原文地址:https://blog.youkuaiyun.com/qq84395064/article/details/86593469?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162548345816780262543220%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=162548345816780262543220&biz转载 2021-07-05 19:12:37 · 199 阅读 · 0 评论 -
linux5.12.2系统调用表
linux-5.12.2\tools\perf\arch\x86\entry\syscalls\syscall_64.tbl547个系统调用原创 2021-07-05 19:03:18 · 110 阅读 · 0 评论 -
Kernel configuration is invalid. include/linux/autoconf.h or include/config/auto.conf are missing
https://blog.youkuaiyun.com/yusiguyuan/article/details/11144941 //刚下载的linux源代码,一个简单的hello驱动都没有编译通过 //下面是驱动源代码 #include <linux/init.h> #include <linux/module.h> static int hello_init(void) { printk(KERN_...原创 2021-07-05 18:59:10 · 1191 阅读 · 1 评论 -
fcntl即F_SETFL,F_GETFL的使用,设置文件的flags
1、获取文件的flags,即open函数的第二个参数: flags = fcntl(fd,F_GETFL,0);2、设置文件的flags:fcntl(fd,F_SETFL,flags);3、增加文件的某个flags,比如文件是阻塞的,想设置成非阻塞: flags = fcntl(fd,F_GETFL,0); flags |= O_NONBLOCK;fcntl(fd,F_SETFL,flags);4、取消文件的某个fl...转载 2020-07-20 23:07:39 · 3683 阅读 · 0 评论 -
signal(SIGPIPE,SIG_IGN)问题
signal(SIGPIPE,SIG_IGN);当服务器close一个连接时,若client端接着发数据。根据TCP协议的规定,会收到一个RST响应,client再往这个服务器发送数据 时,系统会发出一个SIGPIPE信号给进程,告诉进程这个连接已经断开了,不要再写了。根据信号的默认处理规则SIGPIPE信号的默认执行动作是 terminate(终止、退出), 所以client会退出。若不想客户端退出可以把 SIGPIPE设为SIG_IGN如: signal(SIGPIPE,SIG_IGN)...转载 2020-06-22 22:34:44 · 612 阅读 · 0 评论