--- zzzz-none-000/linux-2.4.17/include/linux/sched.h 2001-12-21 17:42:03.000000000 +0000 +++ sangam-fb-322/linux-2.4.17/include/linux/sched.h 2004-11-24 13:21:46.000000000 +0000 @@ -26,6 +26,7 @@ #include #include #include +#include struct exec_domain; @@ -88,6 +89,7 @@ #define TASK_UNINTERRUPTIBLE 2 #define TASK_ZOMBIE 4 #define TASK_STOPPED 8 +#define PREEMPT_ACTIVE 0x40000000 #define __set_task_state(tsk, state_value) \ do { (tsk)->state = (state_value); } while (0) @@ -115,6 +117,21 @@ #define SCHED_OTHER 0 #define SCHED_FIFO 1 #define SCHED_RR 2 +#ifdef CONFIG_RTSCHED +#ifdef CONFIG_MAX_PRI +#if CONFIG_MAX_PRI < 99 +#define MAX_PRI 99 +#elif CONFIG_MAX_PRI > 2047 +#define MAX_PRI 2047 +#else +#define MAX_PRI CONFIG_MAX_PRI +#endif +#else +#define MAX_PRI 127 +#endif +#else +#define MAX_PRI 99 +#endif /* * This is an additional bit set when we want to @@ -154,6 +171,9 @@ #define MAX_SCHEDULE_TIMEOUT LONG_MAX extern signed long FASTCALL(schedule_timeout(signed long timeout)); asmlinkage void schedule(void); +#ifdef CONFIG_PREEMPT +asmlinkage void preempt_schedule(void); +#endif extern int schedule_task(struct tq_struct *task); extern void flush_scheduled_tasks(void); @@ -278,12 +298,46 @@ extern struct user_struct root_user; #define INIT_USER (&root_user) +/* POSIX.1b interval timer structure. */ +struct k_itimer { + struct list_head list; /* free/ allocate list */ + spinlock_t it_lock; + clockid_t it_clock; /* which timer type */ + timer_t it_id; /* timer id */ + int it_overrun; /* overrun on pending signal */ + int it_overrun_last; /* overrun on last delivered signal */ + int it_overrun_deferred; /* overrun on pending timer interrupt */ + int it_sigev_notify; /* notify word of sigevent struct */ + int it_sigev_signo; /* signo word of sigevent struct */ + sigval_t it_sigev_value; /* value word of sigevent struct */ + unsigned long it_incr; /* interval specified in jiffies */ +#ifdef CONFIG_HIGH_RES_TIMERS + int it_sub_incr; /* sub jiffie part of interval */ +#endif + struct task_struct *it_process; /* process to send signal to */ + struct timer_list it_timer; +}; + + +//extern struct itimer_struct *itimer_struct_new(void); +extern void itimer_delete(struct k_itimer *timers); + struct task_struct { /* * offsets of these are hardcoded elsewhere - touch with care */ volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ - unsigned long flags; /* per process flags, defined below */ + /* + * We want the preempt_count in this cache line, but we + * a) don't want to mess up the offsets in asm code, and + * b) the alignment of the next line below, + * so we move "flags" down + * + * Also note we don't make preempt_count volatile, but we do + * need to make sure it is never hiding in a register when + * we have an interrupt, so we need to use barrier() + */ + int preempt_count; /* 0=> preemptable, < 0 => BUG */ int sigpending; mm_segment_t addr_limit; /* thread address space: 0-0xBFFFFFFF for user-thead @@ -319,12 +373,16 @@ * that's just fine.) */ struct list_head run_list; +#ifdef CONFIG_RTSCHED + int counter_recalc; +#endif unsigned long sleep_time; struct task_struct *next_task, *prev_task; struct mm_struct *active_mm; struct list_head local_pages; unsigned int allocation_order, nr_local_pages; + unsigned long flags; /* task state */ struct linux_binfmt *binfmt; @@ -358,6 +416,8 @@ unsigned long it_real_value, it_prof_value, it_virt_value; unsigned long it_real_incr, it_prof_incr, it_virt_incr; struct timer_list real_timer; + struct list_head posix_timers; /* POSIX.1b Interval Timers */ + struct tms times; unsigned long start_time; long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS]; @@ -401,6 +461,10 @@ int (*notifier)(void *priv); void *notifier_data; sigset_t *notifier_mask; +#ifdef CONFIG_RTSCHED + int effprio; /* effective real time priority */ + void (*newprio)(struct task_struct*, int); +#endif /* Thread group tracking */ u32 parent_exec_id; @@ -499,6 +563,7 @@ sig: &init_signals, \ pending: { NULL, &tsk.pending.head, {{0}}}, \ blocked: {{0}}, \ + posix_timers: LIST_HEAD_INIT(tsk.posix_timers), \ alloc_lock: SPIN_LOCK_UNLOCKED, \ journal_info: NULL, \ } @@ -519,7 +584,7 @@ extern struct task_struct *init_tasks[NR_CPUS]; /* PID hashing. (shouldnt this be dynamic?) */ -#define PIDHASH_SZ (4096 >> 2) +#define PIDHASH_SZ (64 >> 2) extern struct task_struct *pidhash[PIDHASH_SZ]; #define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1)) @@ -569,8 +634,23 @@ extern void free_uid(struct user_struct *); #include - -extern unsigned long volatile jiffies; +/* + * The 64-bit value is not volatile - you MUST NOT read it + * without holding read_lock_irq(&xtime_lock) + */ +extern volatile u64 jiffies_64; +/* + * Most people don't necessarily care about the full 64-bit + * value, so we can just get the "unstable" low bits without + * holding the lock. For historical reasons we also mark + * it volatile so that busy-waiting doesn't get optimized + * away in old drivers. + */ +#if defined(__LITTLE_ENDIAN) || (BITS_PER_LONG > 32) +#define jiffies (volatile unsigned long)(((volatile unsigned long *)&jiffies_64)[0]) +#else +#define jiffies (volatile unsigned long)(((volatile unsigned long *)&jiffies_64)[1]) +#endif extern unsigned long itimer_ticks; extern unsigned long itimer_next; extern struct timeval xtime; @@ -782,10 +862,16 @@ extern void exit_mm(struct task_struct *); extern void exit_files(struct task_struct *); extern void exit_sighand(struct task_struct *); +extern void exit_itimers(struct task_struct *); extern void reparent_to_init(void); extern void daemonize(void); +/* Used by core dumps to make sure all the threads the core is taken for + are not running. This just sends SIGSTOP to all the threads. */ +extern int stop_all_threads(struct mm_struct *mm); +extern void start_all_threads(struct mm_struct *mm); + extern int do_execve(char *, char **, char **, struct pt_regs *); extern int do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long); @@ -875,10 +961,16 @@ static inline void del_from_runqueue(struct task_struct * p) { +#ifdef CONFIG_RTSCHED +extern void __del_from_runqueue(struct task_struct * p); + + __del_from_runqueue(p); +#else nr_running--; p->sleep_time = jiffies; list_del(&p->run_list); p->run_list.next = NULL; +#endif } static inline int task_on_runqueue(struct task_struct *p) @@ -927,6 +1019,11 @@ return res; } +#define _TASK_STRUCT_DEFINED +#include +#include +#include + #endif /* __KERNEL__ */ #endif