linux kernel goodness计算分析
来源:互联网 发布:零基础学javascript 编辑:程序博客网 时间:2024/06/12 03:59
今天早上8点过出去买了点东西,回来就赶紧打开source insight看kernel code,跟妹子聊了会天,现在开始分析:
/**这个函数是来确定如何描述一个进程返回值:-1000:从不选择这个0:过期进程,重新计算计数值(但它仍旧可能被选中)正值:goodness值(越大越好)+1000:实时进程,选择这个*/static inline int goodness(struct task_struct * p, int this_cpu, struct mm_struct *this_mm){ int weight; /* * select the current process after every other * runnable process, but before the idle thread. * Also, dont trigger a counter recalculation. */ weight = -1; if (p->policy & SCHED_YIELD) //p->policy表示进程的调度策略,SCHED_YIELD是一种策略,是为了从小分配而让出CPU,就是直接返回啦!#define SCHED_YIELD 0x10 goto out; /* * Non-RT process - normal case first. */ //SCHED_OTHER表示分时调度策略 if (p->policy == SCHED_OTHER) { /* * Give the process a first-approximation goodness value * according to the number of clock-ticks it has left. * * Don't do any other calculations if the time slice is * over.. */ weight = p->counter; if (!weight) goto out; #ifdef CONFIG_SMP /* Give a largish advantage to the same processor... */ /* (this is equivalent to penalizing other processors) */ if (p->processor == this_cpu) weight += PROC_CHANGE_PENALTY;#endif /* .. and a slight advantage to the current MM */ if (p->mm == this_mm || !p->mm) weight += 1; weight += 20 - p->nice; goto out; } /* * Realtime process, select the first one on the * runqueue (taking priorities within processes * into account). */ weight = 1000 + p->rt_priority;out: return weight;}这个函数比较简单吧,就是计算进程goodness值,对于分时策略,会对一些情况weight有些加成;实时进程直接就给最大了。
其实如果木有神马ATT汇编,内核源码看起来还是很爽的,只是写了一个函数,今天计划把进程调度看完,跟书同步吧,至少把书上的字看完呢!
0 0
- linux kernel goodness计算分析
- MDM之Goodness分析报告
- linux kernel初始化分析
- linux kernel 启动分析
- Linux Kernel Interrupt 分析
- Linux kernel浮点计算支持
- Linux kernel printk的分析
- Linux kernel FAT32文件系统分析
- Linux kernel路由机制分析
- Linux kernel路由机制分析
- Linux kernel FAT32文件系统分析
- Linux kernel路由机制分析
- Linux kernel FAT32文件系统分析
- Linux kernel路由机制分析
- Linux Kernel CMPXCHG函数分析
- linux kernel makefile整体分析
- Linux Kernel CMPXCHG函数分析
- Linux kernel Namespace源码分析
- Eclipse调试技巧
- SSH整合时出现的Unable to instantiate Action异常
- 卷积
- java--代理
- 集合(八)
- linux kernel goodness计算分析
- mysql的安装过程
- [Android]应用语言切换的三种方法
- MongoDB MapReduce 性能提升20倍的优化宝典
- 可扩展Web架构与分布式系统
- CF - 408 - B. Garland
- ubuntu 内核管理命令(简单)
- Apache Thrift - 可伸缩的跨语言服务开发框架
- mysql重装过程细节与mysql常见现的错误