4 #include <asm/param.h> /* for HZ */
6 extern unsigned long event
;
8 #include <linux/binfmts.h>
9 #include <linux/personality.h>
10 #include <linux/threads.h>
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/times.h>
14 #include <linux/timex.h>
16 #include <asm/system.h>
17 #include <asm/semaphore.h>
19 #include <asm/ptrace.h>
21 #include <linux/smp.h>
22 #include <linux/tty.h>
23 #include <linux/sem.h>
24 #include <linux/signal.h>
25 #include <linux/securebits.h>
30 #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
31 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
32 #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
33 #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
34 #define CLONE_SIGHAND 0x00000800 /* set if signal handlers shared */
35 #define CLONE_PID 0x00001000 /* set if pid shared */
36 #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
37 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
38 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
41 * These are the constant used to fake the fixed-point load-average
42 * counting. Some notes:
43 * - 11 bit fractions expand to 22 bits by the multiplies: this gives
44 * a load-average precision of 10 bits integer + 11 bits fractional
45 * - if you want to count load-averages more often, you need more
46 * precision, or rounding will get you. With 2-second counting freq,
47 * the EXP_n values would be 1981, 2034 and 2043 if still using only
50 extern unsigned long avenrun
[]; /* Load averages */
52 #define FSHIFT 11 /* nr of bits of precision */
53 #define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
54 #define LOAD_FREQ (5*HZ) /* 5 sec intervals */
55 #define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
56 #define EXP_5 2014 /* 1/exp(5sec/5min) */
57 #define EXP_15 2037 /* 1/exp(5sec/15min) */
59 #define CALC_LOAD(load,exp,n) \
61 load += n*(FIXED_1-exp); \
64 #define CT_TO_SECS(x) ((x) / HZ)
65 #define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ)
67 extern int nr_running
, nr_threads
;
71 #include <linux/time.h>
72 #include <linux/param.h>
73 #include <linux/resource.h>
74 #include <linux/timer.h>
76 #include <asm/processor.h>
78 #define TASK_RUNNING 0
79 #define TASK_INTERRUPTIBLE 1
80 #define TASK_UNINTERRUPTIBLE 2
82 #define TASK_STOPPED 8
83 #define TASK_SWAPPING 16
84 #define TASK_EXCLUSIVE 32
86 #define __set_task_state(tsk, state_value) \
87 do { tsk->state = state_value; } while (0)
89 #define set_task_state(tsk, state_value) \
90 set_mb(tsk->state, state_value)
92 #define set_task_state(tsk, state_value) \
93 __set_task_state(tsk, state_value)
96 #define __set_current_state(state_value) \
97 do { current->state = state_value; } while (0)
99 #define set_current_state(state_value) \
100 set_mb(current->state, state_value)
102 #define set_current_state(state_value) \
103 __set_current_state(state_value)
107 * Scheduling policies
109 #define SCHED_OTHER 0
114 * This is an additional bit set when we want to
115 * yield the CPU for one re-schedule..
117 #define SCHED_YIELD 0x10
124 #define NULL ((void *) 0)
129 #include <linux/spinlock.h>
132 * This serializes "schedule()" and also protects
133 * the run-queue from deletions/modifications (but
134 * _adding_ to the beginning of the run-queue has
137 extern rwlock_t tasklist_lock
;
138 extern spinlock_t runqueue_lock
;
140 extern void sched_init(void);
141 extern void init_idle(void);
142 extern void show_state(void);
143 extern void cpu_init (void);
144 extern void trap_init(void);
146 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
147 extern signed long FASTCALL(schedule_timeout(signed long timeout
));
148 asmlinkage
void schedule(void);
151 * The default fd array needs to be at least BITS_PER_LONG,
152 * as this is the granularity returned by copy_fdset().
154 #define NR_OPEN_DEFAULT BITS_PER_LONG
157 * Open file table structure
159 struct files_struct
{
165 struct file
** fd
; /* current fd array */
166 fd_set
*close_on_exec
;
168 fd_set close_on_exec_init
;
169 fd_set open_fds_init
;
170 struct file
* fd_array
[NR_OPEN_DEFAULT
];
173 #define INIT_FILES { \
179 &init_files.fd_array[0], \
180 &init_files.close_on_exec_init, \
181 &init_files.open_fds_init, \
190 struct dentry
* root
, * pwd
;
199 /* Maximum number of active map areas.. This is a random (large) number */
200 #define MAX_MAP_COUNT (65536)
202 /* Number of map areas at which the AVL tree is activated. This is arbitrary. */
203 #define AVL_MIN_MAP_COUNT 32
206 struct vm_area_struct
* mmap
; /* list of VMAs */
207 struct vm_area_struct
* mmap_avl
; /* tree of VMAs */
208 struct vm_area_struct
* mmap_cache
; /* last find_vma result */
210 atomic_t mm_users
; /* How many users with user space? */
211 atomic_t mm_count
; /* How many references to "struct mm_struct" (users count as 1) */
212 int map_count
; /* number of VMAs */
213 struct semaphore mmap_sem
;
214 spinlock_t page_table_lock
;
215 unsigned long context
;
216 unsigned long start_code
, end_code
, start_data
, end_data
;
217 unsigned long start_brk
, brk
, start_stack
;
218 unsigned long arg_start
, arg_end
, env_start
, env_end
;
219 unsigned long rss
, total_vm
, locked_vm
;
220 unsigned long def_flags
;
221 unsigned long cpu_vm_mask
;
222 unsigned long swap_cnt
; /* number of pages to swap on next pass */
223 unsigned long swap_address
;
225 * This is an architecture-specific pointer: the portable
226 * part of Linux does not know about any segments.
231 #define INIT_MM(name) { \
232 &init_mmap, NULL, NULL, \
234 ATOMIC_INIT(2), ATOMIC_INIT(1), 1, \
235 __MUTEX_INITIALIZER(name.mmap_sem), \
236 SPIN_LOCK_UNLOCKED, \
244 struct signal_struct
{
246 struct k_sigaction action
[_NSIG
];
251 #define INIT_SIGNALS { \
257 * Some day this will be a full-fledged user tracking system..
258 * Right now it is only used to track how many processes a
259 * user has, but it has the potential to track memory usage etc.
264 /* these are hardcoded - don't touch */
265 volatile long state
; /* -1 unrunnable, 0 runnable, >0 stopped */
266 unsigned long flags
; /* per process flags, defined below */
268 mm_segment_t addr_limit
; /* thread address space:
269 0-0xBFFFFFFF for user-thead
270 0-0xFFFFFFFF for kernel-thread
272 struct exec_domain
*exec_domain
;
273 volatile long need_resched
;
279 /* SMP and runqueue state */
283 int lock_depth
; /* Lock depth. We can context switch in and out of holding a syscall kernel lock... */
284 struct task_struct
*next_task
, *prev_task
;
285 struct list_head run_list
;
288 struct linux_binfmt
*binfmt
;
289 int exit_code
, exit_signal
;
290 int pdeath_signal
; /* The signal sent when the parent dies */
292 unsigned long personality
;
299 /* boolean value for session group leader */
302 * pointers to (original) parent process, youngest child, younger sibling,
303 * older sibling, respectively. (p->father can be replaced with
306 struct task_struct
*p_opptr
, *p_pptr
, *p_cptr
, *p_ysptr
, *p_osptr
;
308 /* PID hash table linkage. */
309 struct task_struct
*pidhash_next
;
310 struct task_struct
**pidhash_pprev
;
312 wait_queue_head_t wait_chldexit
; /* for wait4() */
313 struct semaphore
*vfork_sem
; /* for vfork() */
314 unsigned long policy
, rt_priority
;
315 unsigned long it_real_value
, it_prof_value
, it_virt_value
;
316 unsigned long it_real_incr
, it_prof_incr
, it_virt_incr
;
317 struct timer_list real_timer
;
319 unsigned long start_time
;
320 long per_cpu_utime
[NR_CPUS
], per_cpu_stime
[NR_CPUS
];
321 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
322 unsigned long min_flt
, maj_flt
, nswap
, cmin_flt
, cmaj_flt
, cnswap
;
324 /* process credentials */
325 uid_t uid
,euid
,suid
,fsuid
;
326 gid_t gid
,egid
,sgid
,fsgid
;
328 gid_t groups
[NGROUPS
];
329 kernel_cap_t cap_effective
, cap_inheritable
, cap_permitted
;
330 struct user_struct
*user
;
332 struct rlimit rlim
[RLIM_NLIMITS
];
333 unsigned short used_math
;
335 /* file system info */
337 struct tty_struct
*tty
; /* NULL if no tty */
339 struct sem_undo
*semundo
;
340 struct sem_queue
*semsleeping
;
341 /* CPU-specific state of this task */
342 struct thread_struct thread
;
343 /* filesystem information */
344 struct fs_struct
*fs
;
345 /* open file information */
346 struct files_struct
*files
;
348 /* memory management info */
349 struct mm_struct
*mm
, *active_mm
;
351 /* signal handlers */
352 spinlock_t sigmask_lock
; /* Protects signal and blocked */
353 struct signal_struct
*sig
;
354 sigset_t signal
, blocked
;
355 struct signal_queue
*sigqueue
, **sigqueue_tail
;
356 unsigned long sas_ss_sp
;
363 #define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */
364 /* Not implemented yet, only for 486*/
365 #define PF_STARTING 0x00000002 /* being created */
366 #define PF_EXITING 0x00000004 /* getting shut down */
367 #define PF_PTRACED 0x00000010 /* set if ptrace (0) has been called */
368 #define PF_TRACESYS 0x00000020 /* tracing system calls */
369 #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */
370 #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */
371 #define PF_DUMPCORE 0x00000200 /* dumped core */
372 #define PF_SIGNALED 0x00000400 /* killed by a signal */
373 #define PF_MEMALLOC 0x00000800 /* Allocating memory */
374 #define PF_VFORK 0x00001000 /* Wake up parent in mm_release */
376 #define PF_USEDFPU 0x00100000 /* task used FPU this quantum (SMP) */
377 #define PF_DTRACE 0x00200000 /* delayed trace (used on m68k, i386) */
380 * Limit the stack by to some sane default: root can always
381 * increase this limit if needed.. 8MB seems reasonable.
383 #define _STK_LIM (8*1024*1024)
385 #define DEF_PRIORITY (20*HZ/100) /* 200 ms time slices */
388 * INIT_TASK is used to set up the first task table, touch at
389 * your own risk!. Base=0, limit=0x1fffff (=2MB)
391 #define INIT_TASK(name) \
392 /* state etc */ { 0,0,0,KERNEL_DS,&default_exec_domain,0, \
393 /* counter */ DEF_PRIORITY,DEF_PRIORITY,0, \
394 /* SMP */ 0,0,0,-1, \
395 /* schedlink */ &init_task,&init_task, LIST_HEAD_INIT(init_task.run_list), \
397 /* ec,brk... */ 0,0,0,0,0,0, \
398 /* pid etc.. */ 0,0,0,0,0, \
399 /* proc links*/ &init_task,&init_task,NULL,NULL,NULL, \
400 /* pidhash */ NULL, NULL, \
401 /* chld wait */ __WAIT_QUEUE_HEAD_INITIALIZER(name.wait_chldexit), NULL, \
402 /* timeout */ SCHED_OTHER,0,0,0,0,0,0,0, \
403 /* timer */ { NULL, NULL, 0, 0, it_real_fn }, \
404 /* utime */ {0,0,0,0},0, \
405 /* per CPU times */ {0, }, {0, }, \
406 /* flt */ 0,0,0,0,0,0, \
408 /* process credentials */ \
409 /* uid etc */ 0,0,0,0,0,0,0,0, \
410 /* suppl grps*/ 0, {0,}, \
411 /* caps */ CAP_INIT_EFF_SET,CAP_INIT_INH_SET,CAP_FULL_SET, \
413 /* rlimits */ INIT_RLIMITS, \
415 /* comm */ "swapper", \
416 /* fs info */ 0,NULL, \
417 /* ipc */ NULL, NULL, \
418 /* thread */ INIT_THREAD, \
420 /* files */ &init_files, \
421 /* mm */ NULL, &init_mm, \
422 /* signals */ SPIN_LOCK_UNLOCKED, &init_signals, {{0}}, {{0}}, NULL, &init_task.sigqueue, 0, 0, \
425 #ifndef INIT_TASK_SIZE
426 # define INIT_TASK_SIZE 2048*sizeof(long)
430 struct task_struct task
;
431 unsigned long stack
[INIT_TASK_SIZE
/sizeof(long)];
434 extern union task_union init_task_union
;
436 extern struct mm_struct init_mm
;
437 extern struct task_struct
*init_tasks
[NR_CPUS
];
439 /* PID hashing. (shouldnt this be dynamic?) */
440 #define PIDHASH_SZ (4096 >> 2)
441 extern struct task_struct
*pidhash
[PIDHASH_SZ
];
443 #define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
445 extern __inline__
void hash_pid(struct task_struct
*p
)
447 struct task_struct
**htable
= &pidhash
[pid_hashfn(p
->pid
)];
449 if((p
->pidhash_next
= *htable
) != NULL
)
450 (*htable
)->pidhash_pprev
= &p
->pidhash_next
;
452 p
->pidhash_pprev
= htable
;
455 extern __inline__
void unhash_pid(struct task_struct
*p
)
458 p
->pidhash_next
->pidhash_pprev
= p
->pidhash_pprev
;
459 *p
->pidhash_pprev
= p
->pidhash_next
;
462 extern __inline__
struct task_struct
*find_task_by_pid(int pid
)
464 struct task_struct
*p
, **htable
= &pidhash
[pid_hashfn(pid
)];
466 for(p
= *htable
; p
&& p
->pid
!= pid
; p
= p
->pidhash_next
)
472 /* per-UID process charging. */
473 extern int alloc_uid(struct task_struct
*);
474 void free_uid(struct task_struct
*);
476 #include <asm/current.h>
478 extern unsigned long volatile jiffies
;
479 extern unsigned long itimer_ticks
;
480 extern unsigned long itimer_next
;
481 extern struct timeval xtime
;
482 extern void do_timer(struct pt_regs
*);
484 extern unsigned int * prof_buffer
;
485 extern unsigned long prof_len
;
486 extern unsigned long prof_shift
;
488 #define CURRENT_TIME (xtime.tv_sec)
490 extern void FASTCALL(__wake_up(wait_queue_head_t
*q
, unsigned int mode
));
491 extern void FASTCALL(sleep_on(wait_queue_head_t
*q
));
492 extern long FASTCALL(sleep_on_timeout(wait_queue_head_t
*q
,
493 signed long timeout
));
494 extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t
*q
));
495 extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t
*q
,
496 signed long timeout
));
497 extern void FASTCALL(wake_up_process(struct task_struct
* tsk
));
499 #define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
500 #define wake_up_interruptible(x) __wake_up((x),TASK_INTERRUPTIBLE)
502 extern int in_group_p(gid_t
);
504 extern void flush_signals(struct task_struct
*);
505 extern void flush_signal_handlers(struct task_struct
*);
506 extern int dequeue_signal(sigset_t
*, siginfo_t
*);
507 extern int send_sig_info(int, struct siginfo
*, struct task_struct
*);
508 extern int force_sig_info(int, struct siginfo
*, struct task_struct
*);
509 extern int kill_pg_info(int, struct siginfo
*, pid_t
);
510 extern int kill_sl_info(int, struct siginfo
*, pid_t
);
511 extern int kill_proc_info(int, struct siginfo
*, pid_t
);
512 extern int kill_something_info(int, struct siginfo
*, int);
513 extern void notify_parent(struct task_struct
*, int);
514 extern void force_sig(int, struct task_struct
*);
515 extern int send_sig(int, struct task_struct
*, int);
516 extern int kill_pg(pid_t
, int, int);
517 extern int kill_sl(pid_t
, int, int);
518 extern int kill_proc(pid_t
, int, int);
519 extern int do_sigaction(int, const struct k_sigaction
*, struct k_sigaction
*);
520 extern int do_sigaltstack(const stack_t
*, stack_t
*, unsigned long);
522 extern inline int signal_pending(struct task_struct
*p
)
524 return (p
->sigpending
!= 0);
527 /* Reevaluate whether the task has signals pending delivery.
528 This is required every time the blocked sigset_t changes.
529 All callers should have t->sigmask_lock. */
531 static inline void recalc_sigpending(struct task_struct
*t
)
536 switch (_NSIG_WORDS
) {
538 for (i
= _NSIG_WORDS
, ready
= 0; --i
>= 0 ;)
539 ready
|= t
->signal
.sig
[i
] &~ t
->blocked
.sig
[i
];
542 case 4: ready
= t
->signal
.sig
[3] &~ t
->blocked
.sig
[3];
543 ready
|= t
->signal
.sig
[2] &~ t
->blocked
.sig
[2];
544 ready
|= t
->signal
.sig
[1] &~ t
->blocked
.sig
[1];
545 ready
|= t
->signal
.sig
[0] &~ t
->blocked
.sig
[0];
548 case 2: ready
= t
->signal
.sig
[1] &~ t
->blocked
.sig
[1];
549 ready
|= t
->signal
.sig
[0] &~ t
->blocked
.sig
[0];
552 case 1: ready
= t
->signal
.sig
[0] &~ t
->blocked
.sig
[0];
555 t
->sigpending
= (ready
!= 0);
558 /* True if we are on the alternate signal stack. */
560 static inline int on_sig_stack(unsigned long sp
)
562 return (sp
- current
->sas_ss_sp
< current
->sas_ss_size
);
565 static inline int sas_ss_flags(unsigned long sp
)
567 return (current
->sas_ss_size
== 0 ? SS_DISABLE
568 : on_sig_stack(sp
) ? SS_ONSTACK
: 0);
571 extern int request_irq(unsigned int,
572 void (*handler
)(int, void *, struct pt_regs
*),
573 unsigned long, const char *, void *);
574 extern void free_irq(unsigned int, void *);
577 * This has now become a routine instead of a macro, it sets a flag if
578 * it returns true (to do BSD-style accounting where the process is flagged
579 * if it uses root privs). The implication of this is that you should do
580 * normal permissions checks first, and check suser() last.
582 * [Dec 1997 -- Chris Evans]
583 * For correctness, the above considerations need to be extended to
584 * fsuser(). This is done, along with moving fsuser() checks to be
587 * These will be removed, but in the mean time, when the SECURE_NOROOT
588 * flag is set, uids don't grant privilege.
590 extern inline int suser(void)
592 if (!issecure(SECURE_NOROOT
) && current
->euid
== 0) {
593 current
->flags
|= PF_SUPERPRIV
;
599 extern inline int fsuser(void)
601 if (!issecure(SECURE_NOROOT
) && current
->fsuid
== 0) {
602 current
->flags
|= PF_SUPERPRIV
;
609 * capable() checks for a particular capability.
610 * New privilege checks should use this interface, rather than suser() or
611 * fsuser(). See include/linux/capability.h for defined capabilities.
614 extern inline int capable(int cap
)
617 if (cap_raised(current
->cap_effective
, cap
))
619 if (cap_is_fs_cap(cap
) ? current
->fsuid
== 0 : current
->euid
== 0)
622 current
->flags
|= PF_SUPERPRIV
;
629 * Routines for handling mm_structs
631 extern struct mm_struct
* mm_alloc(void);
633 extern struct mm_struct
* start_lazy_tlb(void);
634 extern void end_lazy_tlb(struct mm_struct
*mm
);
636 /* mmdrop drops the mm and the page tables */
637 extern inline void FASTCALL(__mmdrop(struct mm_struct
*));
638 static inline void mmdrop(struct mm_struct
* mm
)
640 if (atomic_dec_and_test(&mm
->mm_count
))
644 /* mmput gets rid of the mappings and all user-space */
645 extern void mmput(struct mm_struct
*);
646 /* Remove the current tasks stale references to the old mm_struct */
647 extern void mm_release(void);
650 * Routines for handling the fd arrays
652 extern struct file
** alloc_fd_array(int);
653 extern int expand_fd_array(struct files_struct
*, int nr
);
654 extern void free_fd_array(struct file
**, int);
656 extern fd_set
*alloc_fdset(int);
657 extern int expand_fdset(struct files_struct
*, int nr
);
658 extern void free_fdset(fd_set
*, int);
660 /* Expand files. Return <0 on error; 0 nothing done; 1 files expanded,
661 * we may have blocked.
663 * Should be called with the files->file_lock spinlock held for write.
665 static inline int expand_files(struct files_struct
*files
, int nr
)
669 printk (KERN_ERR __FUNCTION__
" %d: nr = %d\n", current
->pid
, nr
);
672 if (nr
>= files
->max_fdset
) {
674 if ((err
= expand_fdset(files
, nr
)))
677 if (nr
>= files
->max_fds
) {
679 if ((err
= expand_fd_array(files
, nr
)))
686 printk (KERN_ERR __FUNCTION__
" %d: return %d\n", current
->pid
, err
);
691 extern int copy_thread(int, unsigned long, unsigned long, struct task_struct
*, struct pt_regs
*);
692 extern void flush_thread(void);
693 extern void exit_thread(void);
695 extern void exit_mm(struct task_struct
*);
696 extern void exit_fs(struct task_struct
*);
697 extern void exit_files(struct task_struct
*);
698 extern void exit_sighand(struct task_struct
*);
700 extern int do_execve(char *, char **, char **, struct pt_regs
*);
701 extern int do_fork(unsigned long, unsigned long, struct pt_regs
*);
703 extern inline void add_wait_queue(wait_queue_head_t
*q
, wait_queue_t
* wait
)
707 wq_write_lock_irqsave(&q
->lock
, flags
);
708 __add_wait_queue(q
, wait
);
709 wq_write_unlock_irqrestore(&q
->lock
, flags
);
712 extern inline void add_wait_queue_exclusive(wait_queue_head_t
*q
,
717 wq_write_lock_irqsave(&q
->lock
, flags
);
718 __add_wait_queue_tail(q
, wait
);
719 wq_write_unlock_irqrestore(&q
->lock
, flags
);
722 extern inline void remove_wait_queue(wait_queue_head_t
*q
, wait_queue_t
* wait
)
726 wq_write_lock_irqsave(&q
->lock
, flags
);
727 __remove_wait_queue(q
, wait
);
728 wq_write_unlock_irqrestore(&q
->lock
, flags
);
731 #define __wait_event(wq, condition) \
733 wait_queue_t __wait; \
734 init_waitqueue_entry(&__wait, current); \
736 add_wait_queue(&wq, &__wait); \
738 set_current_state(TASK_UNINTERRUPTIBLE); \
743 current->state = TASK_RUNNING; \
744 remove_wait_queue(&wq, &__wait); \
747 #define wait_event(wq, condition) \
751 __wait_event(wq, condition); \
754 #define __wait_event_interruptible(wq, condition, ret) \
756 wait_queue_t __wait; \
757 init_waitqueue_entry(&__wait, current); \
759 add_wait_queue(&wq, &__wait); \
761 set_current_state(TASK_INTERRUPTIBLE); \
764 if (!signal_pending(current)) { \
768 ret = -ERESTARTSYS; \
771 current->state = TASK_RUNNING; \
772 remove_wait_queue(&wq, &__wait); \
775 #define wait_event_interruptible(wq, condition) \
779 __wait_event_interruptible(wq, condition, __ret); \
783 #define REMOVE_LINKS(p) do { \
784 (p)->next_task->prev_task = (p)->prev_task; \
785 (p)->prev_task->next_task = (p)->next_task; \
787 (p)->p_osptr->p_ysptr = (p)->p_ysptr; \
789 (p)->p_ysptr->p_osptr = (p)->p_osptr; \
791 (p)->p_pptr->p_cptr = (p)->p_osptr; \
794 #define SET_LINKS(p) do { \
795 (p)->next_task = &init_task; \
796 (p)->prev_task = init_task.prev_task; \
797 init_task.prev_task->next_task = (p); \
798 init_task.prev_task = (p); \
799 (p)->p_ysptr = NULL; \
800 if (((p)->p_osptr = (p)->p_pptr->p_cptr) != NULL) \
801 (p)->p_osptr->p_ysptr = p; \
802 (p)->p_pptr->p_cptr = p; \
805 #define for_each_task(p) \
806 for (p = &init_task ; (p = p->next_task) != &init_task ; )
809 static inline void del_from_runqueue(struct task_struct
* p
)
812 list_del(&p
->run_list
);
813 p
->run_list
.next
= NULL
;
816 extern inline int task_on_runqueue(struct task_struct
*p
)
818 return (p
->run_list
.next
!= NULL
);
821 extern inline void unhash_process(struct task_struct
*p
)
823 if (task_on_runqueue(p
)) BUG();
825 write_lock_irq(&tasklist_lock
);
828 write_unlock_irq(&tasklist_lock
);
831 #endif /* __KERNEL__ */