Index: linux-rt/Makefile diff -u linux-rt/Makefile:1.1.1.1 linux-rt/Makefile:1.1.1.1.2.2 --- linux-rt/Makefile:1.1.1.1 Mon Jul 22 09:25:39 2002 +++ linux-rt/Makefile Wed Sep 11 11:10:21 2002 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 18 -EXTRAVERSION = +EXTRAVERSION = -gensched KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) Index: linux-rt/arch/i386/config.in diff -u linux-rt/arch/i386/config.in:1.1.1.1 linux-rt/arch/i386/config.in:1.1.1.1.2.2 --- linux-rt/arch/i386/config.in:1.1.1.1 Mon Jul 22 09:25:41 2002 +++ linux-rt/arch/i386/config.in Tue Aug 27 14:06:32 2002 @@ -201,6 +201,8 @@ if [ "$CONFIG_SMP" = "y" -a "$CONFIG_X86_CMPXCHG" = "y" ]; then define_bool CONFIG_HAVE_DEC_LOCK y fi +#Added by Luca +bool 'Generic Scheduler' CONFIG_GENERIC_SCHEDULER endmenu mainmenu_option next_comment Index: linux-rt/arch/i386/kernel/i386_ksyms.c diff -u linux-rt/arch/i386/kernel/i386_ksyms.c:1.1.1.1 linux-rt/arch/i386/kernel/i386_ksyms.c:1.1.1.1.2.2 --- linux-rt/arch/i386/kernel/i386_ksyms.c:1.1.1.1 Mon Jul 22 09:25:41 2002 +++ linux-rt/arch/i386/kernel/i386_ksyms.c Tue Aug 27 14:06:33 2002 @@ -174,3 +174,11 @@ extern int is_sony_vaio_laptop; EXPORT_SYMBOL(is_sony_vaio_laptop); + +#ifdef CONFIG_GENERIC_SCHEDULER +extern unsigned long fast_gettimeoffset_quotient; +extern unsigned long cpu_khz; +EXPORT_SYMBOL(cpu_khz); +EXPORT_SYMBOL(fast_gettimeoffset_quotient); +#endif /* CONFIG_GENERIC_SCHEDULER */ + Index: linux-rt/arch/ppc/config.in diff -u linux-rt/arch/ppc/config.in:1.1.1.1 linux-rt/arch/ppc/config.in:1.1.1.1.2.2 --- linux-rt/arch/ppc/config.in:1.1.1.1 Mon Jul 22 09:25:41 2002 +++ linux-rt/arch/ppc/config.in Tue Aug 27 14:06:34 2002 @@ -122,6 +122,8 @@ bool 'Math emulation' CONFIG_MATH_EMULATION fi +#Added by Luca +bool 'Generic Scheduler' CONFIG_GENERIC_SCHEDULER endmenu mainmenu_option next_comment Index: linux-rt/arch/ppc/kernel/time.c diff -u linux-rt/arch/ppc/kernel/time.c:1.1.1.1 linux-rt/arch/ppc/kernel/time.c:1.1.1.1.2.1 --- linux-rt/arch/ppc/kernel/time.c:1.1.1.1 Mon Jul 22 09:25:41 2002 +++ linux-rt/arch/ppc/kernel/time.c Mon Nov 4 15:10:01 2002 @@ -93,6 +93,10 @@ EXPORT_SYMBOL(rtc_lock); +#ifdef CONFIG_GENERIC_SCHEDULER +EXPORT_SYMBOL(tb_to_us); +#endif + /* Timer interrupt helper function */ static inline int tb_delta(unsigned *jiffy_stamp) { int delta; Index: linux-rt/include/linux/sched.h diff -u linux-rt/include/linux/sched.h:1.1.1.1 linux-rt/include/linux/sched.h:1.1.1.1.2.8 --- linux-rt/include/linux/sched.h:1.1.1.1 Mon Jul 22 09:25:39 2002 +++ linux-rt/include/linux/sched.h Wed Jan 29 15:11:44 2003 @@ -410,6 +410,9 @@ /* journalling filesystem info */ void *journal_info; +#ifdef CONFIG_GENERIC_SCHEDULER + void *private_data; +#endif /* CONFIG_GENERIC_SCHEDULER */ }; /* @@ -460,6 +463,12 @@ * INIT_TASK is used to set up the first task table, touch at * your own risk!. Base=0, limit=0x1fffff (=2MB) */ +#ifdef CONFIG_GENERIC_SCHEDULER +#define DATA_INIT private_data: NULL, +#else +#define DATA_INIT +#endif /* CONFIG_GENERIC_SCHEDULER */ + #define INIT_TASK(tsk) \ { \ state: 0, \ @@ -501,6 +510,7 @@ blocked: {{0}}, \ alloc_lock: SPIN_LOCK_UNLOCKED, \ journal_info: NULL, \ + DATA_INIT \ } @@ -793,6 +803,15 @@ extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait)); extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)); +#ifdef CONFIG_GENERIC_SCHEDULER +extern void (*block_hook)(struct task_struct *tsk); +extern void (*unblock_hook)(struct task_struct *tsk); +extern void (*fork_hook)(struct task_struct *tsk); +extern void (*cleanup_hook)(struct task_struct *tsk); +extern int (*setsched_hook)(pid_t pid, int policy, struct sched_param *param); +extern int (*getsched_hook)(pid_t pid, struct sched_param *param); +#endif /* CONFIG_GENERIC_SCHEDULER */ + #define __wait_event(wq, condition) \ do { \ wait_queue_t __wait; \ @@ -879,6 +898,11 @@ p->sleep_time = jiffies; list_del(&p->run_list); p->run_list.next = NULL; +#ifdef CONFIG_GENERIC_SCHEDULER + if ((block_hook != NULL) && (p->private_data != NULL)) { + block_hook(p); + } +#endif /* CONFIG_GENERIC_SCHEDULER */ } static inline int task_on_runqueue(struct task_struct *p) Index: linux-rt/kernel/exit.c diff -u linux-rt/kernel/exit.c:1.1.1.1 linux-rt/kernel/exit.c:1.1.1.1.2.2 --- linux-rt/kernel/exit.c:1.1.1.1 Mon Jul 22 09:25:39 2002 +++ linux-rt/kernel/exit.c Tue Aug 27 14:06:36 2002 @@ -20,6 +20,10 @@ #include #include +#ifdef CONFIG_GENERIC_SCHEDULER +void (*cleanup_hook)(struct task_struct *tsk); +#endif /* CONFIG_GENERIC_SCHEDULER */ + extern void sem_exit (void); extern struct task_struct *child_reaper; @@ -450,6 +454,14 @@ lock_kernel(); sem_exit(); + +#ifdef CONFIG_GENERIC_SCHEDULER + /* Is this the correct place for this hook? */ + if (cleanup_hook != NULL) { + cleanup_hook(tsk); + } +#endif + __exit_files(tsk); __exit_fs(tsk); exit_sighand(tsk); Index: linux-rt/kernel/fork.c diff -u linux-rt/kernel/fork.c:1.1.1.1 linux-rt/kernel/fork.c:1.1.1.1.2.3 --- linux-rt/kernel/fork.c:1.1.1.1 Mon Jul 22 09:25:39 2002 +++ linux-rt/kernel/fork.c Tue Aug 27 14:19:01 2002 @@ -26,6 +26,10 @@ #include #include +#ifdef CONFIG_GENERIC_SCHEDULER +void (*fork_hook)(struct task_struct *tsk); +#endif /* CONFIG_GENERIC_SCHEDULER */ + /* The idle threads do not count.. */ int nr_threads; int nr_running; @@ -696,6 +700,13 @@ current->counter >>= 1; if (!current->counter) current->need_resched = 1; + +#ifdef CONFIG_GENERIC_SCHEDULER + p->private_data = NULL; + if (fork_hook != NULL) { + fork_hook(p); + } +#endif /* CONFIG_GENERIC_SCHEDULER */ /* * Ok, add it to the run-queues and make it Index: linux-rt/kernel/ksyms.c diff -u linux-rt/kernel/ksyms.c:1.1.1.1 linux-rt/kernel/ksyms.c:1.1.1.1.2.4 --- linux-rt/kernel/ksyms.c:1.1.1.1 Mon Jul 22 09:25:39 2002 +++ linux-rt/kernel/ksyms.c Wed Jan 29 15:11:46 2003 @@ -559,3 +559,14 @@ EXPORT_SYMBOL(tasklist_lock); EXPORT_SYMBOL(pidhash); + +#ifdef CONFIG_GENERIC_SCHEDULER +extern struct task_struct * init_tasks[NR_CPUS]; +EXPORT_SYMBOL(init_tasks); +EXPORT_SYMBOL(block_hook); +EXPORT_SYMBOL(unblock_hook); +EXPORT_SYMBOL(fork_hook); +EXPORT_SYMBOL(cleanup_hook); +EXPORT_SYMBOL(setsched_hook); +EXPORT_SYMBOL(getsched_hook); +#endif /* CONFIG_GENERIC_SCHEDULER */ Index: linux-rt/kernel/sched.c diff -u linux-rt/kernel/sched.c:1.1.1.1 linux-rt/kernel/sched.c:1.1.1.1.2.4 --- linux-rt/kernel/sched.c:1.1.1.1 Mon Jul 22 09:25:39 2002 +++ linux-rt/kernel/sched.c Wed Jan 29 15:11:46 2003 @@ -33,6 +33,13 @@ #include #include +#ifdef CONFIG_GENERIC_SCHEDULER +void (*block_hook)(struct task_struct *tsk); +void (*unblock_hook)(struct task_struct *tsk); +int (*setsched_hook)(pid_t pid, int policy, struct sched_param *param); +int (*getsched_hook)(pid_t pid, struct sched_param *param); +#endif /* CONFIG_GENERIC_SCHEDULER */ + extern void timer_bh(void); extern void tqueue_bh(void); extern void immediate_bh(void); @@ -326,6 +333,11 @@ { list_add(&p->run_list, &runqueue_head); nr_running++; +#ifdef CONFIG_GENERIC_SCHEDULER + if ((unblock_hook != NULL) && (p->private_data != NULL)) { + unblock_hook(p); + } +#endif /* CONFIG_GENERIC_SCHEDULER */ } static inline void move_last_runqueue(struct task_struct * p) @@ -971,11 +983,31 @@ asmlinkage long sys_sched_setscheduler(pid_t pid, int policy, struct sched_param *param) { +#ifdef CONFIG_GENERIC_SCHEDULER + if (setsched_hook != NULL) { + int res; + + res = setsched_hook(pid, policy, param); + if (res <= 0) { + return res; + } + } +#endif return setscheduler(pid, policy, param); } asmlinkage long sys_sched_setparam(pid_t pid, struct sched_param *param) { +#ifdef CONFIG_GENERIC_SCHEDULER + if (setsched_hook != NULL) { + int res; + + res = setsched_hook(pid, -1, param); + if (res <= 0) { + return res; + } + } +#endif return setscheduler(pid, -1, param); } @@ -1005,6 +1037,16 @@ struct sched_param lp; int retval; +#ifdef CONFIG_GENERIC_SCHEDULER + if (getsched_hook != NULL) { + int res; + + res = getsched_hook(pid, param); + if (res <= 0) { + return res; + } + } +#endif retval = -EINVAL; if (!param || pid < 0) goto out_nounlock;