#include <config.h>
/*
* kernel/sched.c
*
* Kernel scheduler and related syscalls
*
* Copyright (C) 1991-2002 Linus Torvalds
*
* 1996-12-23 Modified by Dave Grothe to fix bugs in semaphores and
* make semaphores SMP safe
* 1998-11-19 Implemented schedule_timeout() and related stuff
* by Andrea Arcangeli
* 2002-01-04 New ultra-scalable O(1) scheduler by Ingo Molnar:
* hybrid priority-list and round-robin design with
* an array-switch method of distributing timeslices
* and per-CPU runqueues. Cleanups and useful suggestions
* by Davide Libenzi, preemptible kernel bits by Robert Love.
* 2003-09-03 Interactivity tuning by Con Kolivas.
* 2004-04-02 Scheduler domains code by Nick Piggin
*/
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/nmi.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <linux/highmem.h>
#include <linux/smp_lock.h>
#include <asm/mmu_context.h>
#include <linux/interrupt.h>
#include <linux/capability.h>
#include <linux/completion.h>
#include <linux/kernel_stat.h>
#include <linux/debug_locks.h>
#include <linux/security.h>
#include <linux/notifier.h>
#include <linux/profile.h>
#include <linux/freezer.h>
#include <linux/vmalloc.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/smp.h>
#include <linux/threads.h>
#include <linux/timer.h>
#include <linux/rcupdate.h>
#include <linux/cpu.h>
#include <linux/cpuset.h>
#include <linux/percpu.h>
#include <linux/kthread.h>
#include <linux/seq_file.h>
#include <linux/syscalls.h>
#include <linux/times.h>
#include <linux/tsacct_kern.h>
#include <linux/kprobes.h>
#include <linux/delayacct.h>
#include <linux/reciprocal_div.h>
#include <asm/tlb.h>
#include <asm/unistd.h>
///*
// * Scheduler clock - returns current time in nanosec units.
// * This is default implementation.
// * Architectures and sub-architectures can override this.
// */
//unsigned long long __attribute__((weak)) sched_clock(void)
//{
// return (unsigned long long)jiffies * (1000000000 / HZ);
//}
//
///*
// * Convert user-nice values [ -20 ... 0 ... 19 ]
// * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
// * and back.
// */
//#define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20)
//#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
//#define TASK_NICE(p) PRIO_TO_NICE((p)->static_prio)
//
///*
// * 'User priority' is the nice value converted to something we
// * can work with better when scaling various scheduler parameters,
// * it's a [ 0 ... 39 ] range.
// */
//#define USER_PRIO(p) ((p)-MAX_RT_PRIO)
//#define TASK_USER_PRIO(p) USER_PRIO((p)->static_prio)
//#define MAX_USER_PRIO (USER_PRIO(MAX_PRIO))
//
///*
// * Some helpers for converting nanosecond timing to jiffy resolution
// */
//#define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ))
//#define JIFFIES_TO_NS(TIME) ((TIME) * (1000000000 / HZ))
//
///*
// * These are the 'tuning knobs' of the scheduler:
// *
// * Minimum timeslice is 5 msecs (or 1 jiffy, whichever is larger),
// * default timeslice is 100 msecs, maximum timeslice is 800 msecs.
// * Timeslices get refilled after they expire.
// */
//#define MIN_TIMESLICE max(5 * HZ / 1000, 1)
//#define DEF_TIMESLICE (100 * HZ / 1000)
//#define ON_RUNQUEUE_WEIGHT 30
//#define CHILD_PENALTY 95
//#define PARENT_PENALTY 100
//#define EXIT_WEIGHT 3
//#define PRIO_BONUS_RATIO 25
//#define MAX_BONUS (MAX_USER_PRIO * PRIO_BONUS_RATIO / 100)
//#define INTERACTIVE_DELTA 2
//#define MAX_SLEEP_AVG (DEF_TIMESLICE * MAX_BONUS)
//#define STARVATION_LIMIT (MAX_SLEEP_AVG)
//#define NS_MAX_SLEEP_AVG (JIFFIES_TO_NS(MAX_SLEEP_AVG))
//
///*
// * If a task is 'interactive' then we reinsert it in the active
// * array after it has expired its current timeslice. (it will not
// * continue to run immediately, it will still roundrobin with
// * other interactive tasks.)
// *
// * This part scales the interactivity limit depending on niceness.
// *
// * We scale it linearly, offset by the INTERACTIVE_DELTA delta.
// * Here are a few examples of different nice levels:
// *
// * TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,0,0]
// * TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,0,0,0,0]
// * TASK_INTERACTIVE( 0): [1,1,1,1,0,0,0,0,0,0,0]
// * TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0]
// * TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0]
// *
// * (the X axis represents the possible -5 ... 0 ... +5 dynamic
// * priority range a task can explore, a value of '1' means the
// * task is rated interactive.)
// *
// * Ie. nice +19 tasks can never get 'interactive' enough to be
// * reinserted into the active array. And only heavily CPU-hog nice -20
// * tasks will be expired. Default nice 0 tasks are somewhere between,
// * it takes some effort for them to get interactive, but it's not
// * too hard.
// */
//
//#define CURRENT_BONUS(p) \
// (NS_TO_JIFFIES((p)->sleep_avg) * MAX_BONUS / \
// MAX_SLEEP_AVG)
//
//#define GRANULARITY (10 * HZ / 1000 ? : 1)
//
//#ifdef CONFIG_SMP
//#define TIMESLICE_GRANULARITY(p) (GRANULARITY * \
// (1 << (((MAX_BONUS - CURRENT_BONUS(p)) ? : 1) - 1)) * \
// num_online_cpus())
//#else
//#define TIMESLICE_GRANULARITY(p) (GRANULARITY * \
// (1 << (((MAX_BONUS - CURRENT_BONUS(p)) ? : 1) - 1)))
//#endif
//
//#define SCALE(v1,v1_max,v2_max) \
// (v1) * (v2_max) / (v1_max)
//
//#define DELTA(p) \
// (SCALE(TASK_NICE(p) + 20, 40, MAX_BONUS) - 20 * MAX_BONUS / 40 + \
// INTERACTIVE_DELTA)
//
//#define TASK_INTERACTIVE(p) \
// ((p)->prio <= (p)->static_prio - DELTA(p))
//
//#define INTERACTIVE_SLEEP(p) \
// (JIFFIES_TO_NS(MAX_SLEEP_AVG * \
// (MAX_BONUS / 2 + DELTA((p)) + 1) / MAX_BONUS - 1))
//
//#define TASK_PREEMPTS_CURR(p, rq) \
// ((p)->prio < (rq)->curr->prio)
//
//#define SCALE_PRIO(x, prio) \
// max(x * (MAX_PRIO - prio) / (MAX_USER_PRIO / 2), MIN_TIMESLICE)
//
//static unsigned int static_prio_timeslice(int static_prio)
//{
// if (static_prio < NICE_TO_PRIO(0))
// return SCALE_PRIO(DEF_TIMESLICE * 4, static_prio);
// else
// return SCALE_PRIO(DEF_TIMESLICE, static_prio);
//}
//
//#ifdef CONFIG_SMP
///*
// * Divide a load by a sched group cpu_power : (load / sg->__cpu_power)
// * Since cpu_power is a 'constant', we can use a reciprocal divide.
// */
//static inline u32 sg_div_cpu_power(const struct sched_group *sg, u32 load)
//{
// return reciprocal_divide(load, sg->reciprocal_cpu_power);
//}
//
///*
// * Each time a sched group cpu_power is changed,
// * we must compute its reciprocal value
// */
//static inline void sg_inc_cpu_power(struct sched_group *sg, u32 val)
//{
// sg->__cpu_power += val;
// sg->reciprocal_cpu_power = reciprocal_value(sg->__cpu_power);
//}
//#endif
//
///*
// * task_timeslice() scales user-nice values [ -20 ... 0 ... 19 ]
// * to time slice values: [800ms ... 100ms ... 5ms]
// *
// * The higher a thread's priority, the bigger timeslices
// * it gets during one round of execution. But even the lowest
// * priority thread gets MIN_TIMESLICE worth of execution time.
// */
//
//static inline unsigned int task_timeslice(struct task_struct *p)
//{
// return static_prio_timeslice(p->static_prio);
//}
//
///*
// * These are the runqueue data structures:
// */
//
//struct prio_array {
// unsigned int nr_active;
// DECLARE_BITMAP(bitmap, MAX_PRIO+1); /* include 1 bit for delimiter */
// struct list_head queue[MAX_PRIO];
//};
//
///*
// * This is the main, per-CPU runqueue data structure.
// *
// * Locking rule: those places that want to lock multiple runqueues
// * (such as the load balancing or the thread migration code), lock
// * acquire operations must be ordered by ascending &runqueue.
// */
//struct rq {
// spinlock_t lock;
//
// /*
// * nr_running and cpu_load should be in the same cacheline because
// * remote CPUs use both these fields when doing load calculation.
没有合适的资源?快使用搜索试试~ 我知道了~
memsim_csdn_0.1
共2000个文件
h:2254个
o:40个
kbuild:25个
需积分: 9 37 下载量 152 浏览量
2008-08-04
16:34:56
上传
评论
收藏 3.59MB RAR 举报
温馨提示
这个是对uclinux内核的内存管理进行模拟的工程,包含bootmem, buddy, slab三种算法。<br>使用的开发工具为:<br>cygwin gcc 3.4.4<br>CodeBlocks IDE<br>bfin-uclinux-2008-r1<br>它删除了开关中断,同步及调度相关的代码。<br>使用了CodeBlocks 8做为IDE,这样就可以方便地进行跟踪调试,对理解uclinux的内存管理有一定的参考价值。<br><br><br>快乐虾<br>http://blog.csdn.net/lights_joy/<br>lights@hb165.com<br><br>Enjoy!<br>
资源推荐
资源详情
资源评论
收起资源包目录
memsim_csdn_0.1 (2000个子文件)
sched.c 202KB
slab.c 128KB
page_alloc.c 100KB
memory.c 83KB
vmscan.c 53KB
bitmap.c 26KB
init_main.c 23KB
setup.c 22KB
vmstat.c 19KB
bootmem.c 13KB
mutex.c 10KB
wait.c 8KB
panic.c 8KB
mm_init.c 7KB
find_next_bit.c 5KB
util.c 2KB
div64.c 2KB
hweight.c 2KB
main.c 1KB
reciprocal_div.c 191B
defBF54x_base.h 250KB
defBF534.h 189KB
defBF549.h 181KB
cdefBF54x_base.h 169KB
cdefBF534.h 126KB
cdefBF549.h 117KB
defBF548.h 117KB
defBF52x_base.h 116KB
cdefBF561.h 114KB
radeon.h 112KB
security.h 111KB
defBF561.h 105KB
cdefBF548.h 100KB
emu10k1.h 100KB
reiserfs_fs.h 95KB
pci_ids.h 94KB
defBF527.h 77KB
fs.h 75KB
cs46xx.h 75KB
defBF532.h 74KB
mv643xx.h 73KB
cdefBF52x_base.h 72KB
structs.h 64KB
cdefBF544.h 62KB
usb.h 61KB
ib_verbs.h 58KB
defBF542.h 58KB
defBF544.h 57KB
sched.h 54KB
videodev2.h 54KB
pm3fb.h 53KB
soundcard.h 49KB
mach64.h 49KB
skbuff.h 49KB
cdefBF532.h 48KB
ide.h 47KB
defBF525.h 45KB
wireless.h 44KB
mac80211.h 43KB
mm.h 42KB
ieee80211.h 42KB
fb.h 42KB
asound.h 41KB
sock.h 40KB
libata.h 40KB
i2o.h 40KB
tcp.h 40KB
ufs_fs.h 39KB
actypes.h 39KB
cdrom.h 38KB
pcm.h 38KB
cdefBF527.h 38KB
jbd2.h 37KB
usb_gadget.h 36KB
nf_conntrack_h323_types.h 36KB
ext4_fs.h 36KB
jbd.h 36KB
cdefBF542.h 35KB
zlib.h 35KB
input.h 35KB
pci.h 35KB
defBF537.h 35KB
asequencer.h 34KB
netdevice.h 34KB
aclocal.h 34KB
ip_vs.h 33KB
xfrm.h 32KB
isdn.h 31KB
ext3_fs.h 31KB
cs46xx_dsp_scb_types.h 31KB
sysctl.h 31KB
netlink.h 31KB
zorro_ids.h 30KB
list.h 30KB
def_LPBlackfin.h 30KB
i2c.h 29KB
ac97_codec.h 29KB
syscalls.h 28KB
crypto.h 28KB
acmacros.h 28KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
嵌云阁主
- 粉丝: 1136
- 资源: 55
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功