--- linux-2.4.0-test3-pre4/mm/filemap.c Thu Jul 6 20:23:47 2000 +++ linux-akpm/mm/filemap.c Sat Jul 8 14:33:54 2000 @@ -160,6 +160,7 @@ start = (lstart + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; repeat: + conditional_schedule(); /* sys_unlink() */ head = &mapping->pages; spin_lock(&pagecache_lock); curr = head->next; @@ -450,6 +451,7 @@ page_cache_get(page); spin_unlock(&pagecache_lock); + conditional_schedule(); /* sys_sync() */ lock_page(page); /* The buffers could have been free'd while we waited for the page lock */ @@ -1081,6 +1083,8 @@ * "pos" here (the actor routine has to update the user buffer * pointers and the remaining count). */ + conditional_schedule(); /* sys_read() */ + nr = actor(desc, page, offset, nr); offset += nr; index += offset >> PAGE_CACHE_SHIFT; @@ -1533,6 +1537,7 @@ * vma/file is guaranteed to exist in the unmap/sync cases because * mmap_sem is held. */ + conditional_schedule(); /* sys_msync() */ return page->mapping->a_ops->writepage(file, page); } @@ -2486,6 +2491,8 @@ while (count) { unsigned long bytes, index, offset; char *kaddr; + + conditional_schedule(); /* sys_write() */ /* * Try to find the page in the cache. If it isn't there, --- linux-2.4.0-test3-pre4/fs/buffer.c Thu Jul 6 20:23:47 2000 +++ linux-akpm/fs/buffer.c Sat Jul 8 14:34:08 2000 @@ -2123,6 +2123,7 @@ __wait_on_buffer(p); } else if (buffer_dirty(p)) ll_rw_block(WRITE, 1, &p); + conditional_schedule(); /* sys_msync() */ } while (tmp != bh); } --- linux-2.4.0-test3-pre4/include/linux/sched.h Thu Jul 6 20:23:47 2000 +++ linux-akpm/include/linux/sched.h Sat Jul 8 15:15:03 2000 @@ -146,6 +146,8 @@ extern signed long FASTCALL(schedule_timeout(signed long timeout)); asmlinkage void schedule(void); +#define conditional_schedule() do { if (current->need_resched) schedule(); } while (0) + /* * The default fd array needs to be at least BITS_PER_LONG, * as this is the granularity returned by copy_fdset(). @@ -348,6 +350,8 @@ u32 self_exec_id; /* Protection of (de-)allocation: mm, files, fs, tty */ spinlock_t alloc_lock; + + int curr_syscall; }; /* @@ -423,6 +427,7 @@ blocked: {{0}}, \ sigqueue: NULL, \ sigqueue_tail: &tsk.sigqueue, \ + curr_syscall: 0, \ alloc_lock: SPIN_LOCK_UNLOCKED \ }