《Linux内核完全注释V3 0 pdf》 + Linux 0 11注释源码 + Linux 0 12 源码 这是由赵炯所写的 是Linux 内核开发来说相当不错的书籍 附带有注释的0 11源码 还有原生没注释的0 12源码 可以在source inside中对照查看 方便查找 对于学习内核是相当有帮助的 参考源码示例: 0 11注释 "schedule " is the scheduler function This is GOOD CODE There probably won"t be any reason to change this as it should work well in all circumstances ie gives IO bound processes good response etc The one thing you might take a look at is the signal handler code here NOTE Task 0 is the "idle" task which gets called when no other tasks can run It can not be killed and it cannot sleep The "state" information in task[0] is never used "schedule "是调度函数 这是个很好的代码 没有任何理由对它进行修改 因为它可以在所有的 环境下工作(比如能够对IO 边界处理很好的响应等) 只有一件事值得留意 那就是这里的信号 处理代码 注意 任务0 是个闲置 "idle" 任务 只有当没有其它任务可以运行时才调用它 它不能被杀 死 也不能睡眠 任务0 中的状态信息"state"是从来不用的 void schedule void { int i next c; struct task struct p; 任务结构指针的指针 check alarm wake up any interruptible tasks that have got a signal 检测alarm(进程的报警定时值) 唤醒任何已得到信号的可中断任务 从任务数组中最后一个任务开始检测alarm for p &LAST; TASK; p > &FIRST; TASK; p if p { 如果任务的alarm 时间已经过期 alarm<jiffies 则在信号位图中置SIGALRM 信号 然后清alarm jiffies 是系统从开机开始算起的滴答数(10ms 滴答) 定义在sched h 第139 行 if p >alarm && p >alarm < jiffies { p >signal | 1 << SIGALRM 1 ; p >alarm 0; } 如果信号位图中除被阻塞的信号外还有其它信号 并且任务处于可中断状态 则置任务为就绪状态 其中" BLOCKABLE & p >blocked "用于忽略被阻塞的信号 但SIGKILL 和SIGSTOP 不能被阻塞 if p >signal & BLOCKABLE & p >blocked && p >state TASK INTERRUPTIBLE p >state TASK RUNNING; 置为就绪(可执行)状态 } this is the scheduler proper: 这里是调度程序的主要部分 while 1 { c 1; next 0; i NR TASKS; p &task;[NR TASKS]; 这段代码也是从任务数组的最后一个任务开始循环处理 并跳过不含任务的数组槽 比较每个就绪 状态任务的counter(任务运行时间的递减滴答计数)值 哪一个值大 运行时间还不长 next 就 指向哪个的任务号 while i { if p continue; if p >state TASK RUNNING && p >counter > c c p >counter next i; } 如果比较得出有counter 值大于0 的结果 则退出124 行开始的循环 执行任务切换(141 行) if c break; 否则就根据每个任务的优先权值 更新每一个任务的counter 值 然后回到125 行重新比较 counter 值的计算方式为counter counter 2 + priority [右边counter 0 ] for p &LAST; TASK; p > &FIRST; TASK; p if p p >counter p >counter >> 1 + p >priority; } switch to next ; 切换到任务号为next 的任务 并运行之 } 0 12 "schedule " is the scheduler function This is GOOD CODE There probably won"t be any reason to change this as it should work well in all circumstances ie gives IO bound processes good response etc The one thing you might take a look at is the signal handler code here NOTE Task 0 is the "idle" task which gets called when no other tasks can run It can not be killed and it cannot sleep The "state" information in task[0] is never used void schedule void { int i next c; struct task struct p; check alarm wake up any interruptible tasks that have got a signal for p &LAST; TASK ; p > &FIRST; TASK ; p if p { if p >timeout && p >timeout < jiffies { p >timeout 0; if p >state TASK INTERRUPTIBLE p >state TASK RUNNING; } if p >alarm && p >alarm < jiffies { p >signal | 1<< SIGALRM 1 ; p >alarm 0; } if p >signal & BLOCKABLE & p >blocked && p >state TASK INTERRUPTIBLE p >state TASK RUNNING; } this is the scheduler proper: while 1 { c 1; next 0; i NR TASKS; p &task;[NR TASKS]; while i { if p continue; if p >state TASK RUNNING && p >counter > c c p >counter next i; } if c break; for p &LAST; TASK ; p > &FIRST; TASK ; p if p p >counter p >counter >> 1 + p >priority; } switch to next ; }">《Linux内核完全注释V3 0 pdf》 + Linux 0 11注释源码 + Linux 0 12 源码 这是由赵炯所写的 是Linux 内核开发来说相当不错的书籍 附带有注释的0 11源码 还有原生没注释的0 12源码 可以在source inside中对照查看 方便查找 对于学习 [更多]
2024-04-18 17:11:19 7.5MB V0.12 Linux
1
分享数据库驱动包!真是好用,同时兼容8.0.12以下的版本
2024-04-03 17:13:03 5.46MB mysql驱动
1
【虚拟机安装包VirtualBox-7.0.12-159484-Win】
2023-12-30 05:19:56 105.47MB
1
Java Development Kit (64bit) v11 11.0.12
2023-11-22 08:52:17 150.24MB Java jdk11
1
生产环境下,离线安装Flannel与etcd,让不同主机上的Docker容器之间相互通信etcd-v3.0.12-linux-amd64.tar.gz flannel-v0.11.0-linux-amd64.tar.gz
1
VirtualBox 是一款开源虚拟机软件。VirtualBox 是由德国 Innotek 公司开发,由Sun Microsystems公司出品的软件,使用Qt编写,在 Sun 被 Oracle 收购后正式更名成 Oracle VM VirtualBox。
2023-01-31 17:02:47 162.56MB 虚拟机 VirtualBox
1
【iqiqiya专版】千图网和千库网无水印解析下载工具
1
Fingers - Touch Gestures for Unity 3.0.12
2022-12-28 18:27:58 5.39MB unity
1
Zotero是一种好用的文献管理开源软件
2022-12-21 14:20:22 64.79MB 文献 zotero
1
内存超频必备,TestMem5 v0.12 (best configs),日常用Heavy5opt@anta777烤一圈,基本就稳定,要狠一点就Extreme1@anta777跑5圈。
2022-12-19 12:27:22 50KB testmen5 超频 tm5 配置文件
1