linux进程调度 源码分析,Linux进程调度源代码分析

Linux进程调度源代码sched.c分析

/*

* linux/kernel/sched.c

*

* Copyright (C) 1991, 1992 Linus Torvalds

*

* 1996-12-23 Modified by Dave Grothe to fix bugs in semaphores and

* make semaphores SMP (对称多处理机) safe

* 1997-01-28 Modified by Finn Arne Gangstad to make timers scale better.

* 1997-09-10Updated NTP code according to technical memorandum Jan '96

*"A Kernel Model for Precision Timekeeping" by Dave Mills

* 1998-11-19Implemented schedule_timeout() and related stuff

*by Andrea Arcangeli

* 1998-12-24Fixed a xtime SMP race (we need the xtime_lock rw spinlock to

*serialize accesses to xtime/lost_ticks).

*Copyright (C) 1998 Andrea Arcangeli

* 1998-12-28 Implemented better SMP scheduling by Ingo Molnar

* 1999-03-10Improved NTP compatibility by Ulrich Windl

*/

/*

* 'sched.c' is the main kernel file. It contains scheduling primitives

* (sleep_on, wakeup, schedule etc) as well as a number of simple system

* call functions (type getpid()), which just extract a field from

* current-task

*/

#include //内存管理头文件

#include //包含了一些rstatd/perfmeter */使用的内核统计的所需的定义

#include //软盘系统头文件

#include //延时头文件

#include //包含了与中断相关的大部分宏及struct结构的定义

#include //SMP自旋锁头文件

#include //初始化头文件

#include //io头文件,定义硬件短裤输入输出宏汇编语句

#include //用户空间内存访问头文件

#include //包含了修改和使用i386页表树的必要的函数和定义

#include //NOMMU架构的通用钩头文件

#include //

#include //计算命令的时间,报告进程数据和系统活动的头文件

/*

* kernel variables

*/

unsigned securebits = SECUREBITS_DEFAULT; /* systemwide security settings *///系统范围的安全设置

long tick = (1000000 + HZ/2) / HZ;/* timer interrupt period *///定时器中断周期

/* The current time *///Linux内核通过timeval结构类型的全局变量xtime来维持当前时间

volatile struct timeval xtime __attribute__ ((aligned (16)));//volatile被设计用来修饰被不同线程访问和修改的变量

/* Don't completely fail for HZ > 500. */

int tickadj = 500/HZ ? : 1;/* microsecs *///时钟滴答校准(微秒)

//定义任务队列tq_timer、tq_immediate、tq_scheduler

DECLARE_TASK_QUEUE(tq_timer);

DECLARE_TASK_QUEUE(tq_immediate);

DECLARE_TASK_QUEUE(tq_scheduler);

/*

* phase-lock loop variables

*/

/* TIME_ERROR prevents overwriting the CMOS clock */

int time_state = TIME_OK;/* clock synchronization status */

int time

_status = STA_UNSYNC;/* clock status bits */

long time_offset = 0;/* time adjustment (us) */

long time_constant = 2;/* pll time constant

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值