📄 00000031.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: foxsen (曙光初现), 信区: Linux <BR>标 题: Re: linux运行多任务难到这么难么 <BR>发信站: BBS 水木清华站 (Fri Oct 6 18:59:49 2000) <BR> <BR>这里有一个简化版的for 2.4.0-test8 <BR>--- linux-2.4.0-test8/include/linux/sched.h Sat Sep 9 16:19:30 2000 <BR>+++ linux-akpm/include/linux/sched.h Tue Sep 12 19:45:11 2000 <BR>@@ -150,6 +150,9 @@ <BR> extern signed long FASTCALL(schedule_timeout(signed long timeout)); <BR> asmlinkage void schedule(void); <BR> <BR>+#define conditional_schedule_needed() (current->need_resched) <BR>+#define conditional_schedule() do { if <BR>(conditional_schedule_needed()) schedule(); } while (0) <BR>+ <BR> /* <BR> * The default fd array needs to be at least BITS_PER_LONG, <BR> * as this is the granularity returned by copy_fdset(). <BR>--- linux-2.4.0-test8/include/linux/mm.h Sat Sep 9 16:19:30 2000 <BR>+++ linux-akpm/include/linux/mm.h Tue Sep 12 19:45:11 2000 <BR>@@ -179,6 +179,10 @@ <BR> /* bits 21-30 unused */ <BR> #define PG_reserved 31 <BR> <BR>+/* Actions for zap_page_range() */ <BR>+#define ZPR_FLUSH_CACHE 1 /* Do flush_cache_range() prior to releasing <BR> pages */ <BR>+#define ZPR_FLUSH_TLB 2 /* Do flush_tlb_range() after releasing <BR>pages */ <BR>+#define ZPR_COND_RESCHED 4 /* Do a conditional_schedule() <BR>occasionally */ <BR> <BR> /* Make it prettier to test the above... */ <BR> #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags) <BR>@@ -360,7 +364,7 @@ <BR> <BR> extern int map_zero_setup(struct vm_area_struct *); <BR> <BR>-extern void zap_page_range(struct mm_struct *mm, unsigned long address, <BR> unsigned long size); <BR>+extern void zap_page_range(struct mm_struct *mm, unsigned long address, <BR> unsigned long size, int actions); <BR> extern int copy_page_range(struct mm_struct *dst, struct mm_struct <BR>*src, struct vm_area_struct *vma); <BR> extern int remap_page_range(unsigned long from, unsigned long to, <BR>unsigned long size, pgprot_t prot); <BR> extern int zeromap_page_range(unsigned long from, unsigned long size, <BR>pgprot_t prot); <BR>--- linux-2.4.0-test8/mm/filemap.c Sat Sep 9 16:19:30 2000 <BR>+++ linux-akpm/mm/filemap.c Tue Sep 12 19:36:55 2000 <BR>@@ -191,6 +191,7 @@ <BR> start = (lstart + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; <BR> <BR> repeat: <BR>+ conditional_schedule(); /* sys_unlink() */ <BR> head = &mapping->pages; <BR> spin_lock(&pagecache_lock); <BR> curr = head->next; <BR>@@ -252,6 +253,8 @@ <BR> /* we need pagemap_lru_lock for list_del() ... subtle code below */ <BR> spin_lock(&pagemap_lru_lock); <BR> while (count > 0 && (page_lru = lru_cache.prev) != &lru_cache) { <BR>+ if (conditional_schedule_needed()) <BR>+ goto out_resched; <BR> page = list_entry(page_lru, struct page, lru); <BR> list_del(page_lru); <BR> <BR>@@ -368,6 +371,10 @@ <BR> spin_unlock(&pagemap_lru_lock); <BR> <BR> return ret; <BR>+out_resched: <BR>+ spin_unlock(&pagemap_lru_lock); <BR>+ schedule(); <BR>+ return ret; <BR> } <BR> <BR> static inline struct page * __find_page_nolock(struct address_space <BR>*mapping, unsigned long offset, struct page *page) <BR>@@ -446,6 +453,7 @@ <BR> <BR> page_cache_get(page); <BR> spin_unlock(&pagecache_lock); <BR>+ conditional_schedule(); /* sys_msync() */ <BR> lock_page(page); <BR> <BR> /* The buffers could have been free'd while we waited for the page <BR>lock */ <BR>@@ -1081,6 +1089,7 @@ <BR> * "pos" here (the actor routine has to update the user buffer <BR> * pointers and the remaining count). <BR> */ <BR>+ conditional_schedule(); /* sys_read() */ <BR> nr = actor(desc, page, offset, nr); <BR> offset += nr; <BR> index += offset >> PAGE_CACHE_SHIFT; <BR>@@ -1533,6 +1542,7 @@ <BR> * vma/file is guaranteed to exist in the unmap/sync cases because <BR> * mmap_sem is held. <BR> <BR> */ <BR>+ conditional_schedule(); /* sys_msync() */ <BR> return page->mapping->a_ops->writepage(file, page); <BR> } <BR> <BR>@@ -1670,6 +1680,7 @@ <BR> if (address >= end) <BR> BUG(); <BR> do { <BR>+ conditional_schedule(); /* unmapping large mapped files */ <BR> error |= filemap_sync_pmd_range(dir, address, end - address, vma, <BR>flags); <BR> address = (address + PGDIR_SIZE) & PGDIR_MASK; <BR> dir++; <BR>@@ -2020,9 +2031,8 @@ <BR> if (vma->vm_flags & VM_LOCKED) <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -