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);
145 extern void update_one_process( struct task_struct
*p
,
146 unsigned long ticks
, unsigned long user
, unsigned long system
, int cpu
);
148 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
149 extern signed long FASTCALL(schedule_timeout(signed long timeout
));
150 asmlinkage
void schedule(void);
153 * The default fd array needs to be at least BITS_PER_LONG,
154 * as this is the granularity returned by copy_fdset().
156 #define NR_OPEN_DEFAULT BITS_PER_LONG
159 * Open file table structure
161 struct files_struct
{
167 struct file
** fd
; /* current fd array */
168 fd_set
*close_on_exec
;
170 fd_set close_on_exec_init
;
171 fd_set open_fds_init
;
172 struct file
* fd_array
[NR_OPEN_DEFAULT
];
175 #define INIT_FILES { \
181 &init_files.fd_array[0], \
182 &init_files.close_on_exec_init, \
183 &init_files.open_fds_init, \
192 struct dentry
* root
, * pwd
;
201 /* Maximum number of active map areas.. This is a random (large) number */
202 #define MAX_MAP_COUNT (65536)
204 /* Number of map areas at which the AVL tree is activated. This is arbitrary. */
205 #define AVL_MIN_MAP_COUNT 32
208 struct vm_area_struct
* mmap
; /* list of VMAs */
209 struct vm_area_struct
* mmap_avl
; /* tree of VMAs */
210 struct vm_area_struct
* mmap_cache
; /* last find_vma result */
212 atomic_t mm_users
; /* How many users with user space? */
213 atomic_t mm_count
; /* How many references to "struct mm_struct" (users count as 1) */
214 int map_count
; /* number of VMAs */
215 struct semaphore mmap_sem
;
216 spinlock_t page_table_lock
;
217 unsigned long context
;
218 unsigned long start_code
, end_code
, start_data
, end_data
;
219 unsigned long start_brk
, brk
, start_stack
;
220 unsigned long arg_start
, arg_end
, env_start
, env_end
;
221 unsigned long rss
, total_vm
, locked_vm
;
222 unsigned long def_flags
;
223 unsigned long cpu_vm_mask
;
224 unsigned long swap_cnt
; /* number of pages to swap on next pass */
225 unsigned long swap_address
;
227 * This is an architecture-specific pointer: the portable
228 * part of Linux does not know about any segments.
233 #define INIT_MM(name) { \
234 &init_mmap, NULL, NULL, \
236 ATOMIC_INIT(2), ATOMIC_INIT(1), 1, \
237 __MUTEX_INITIALIZER(name.mmap_sem), \
238 SPIN_LOCK_UNLOCKED, \
246 struct signal_struct
{
248 struct k_sigaction action
[_NSIG
];
253 #define INIT_SIGNALS { \
259 * Some day this will be a full-fledged user tracking system..
260 * Right now it is only used to track how many processes a
261 * user has, but it has the potential to track memory usage etc.
266 /* these are hardcoded - don't touch */
267 volatile long state
; /* -1 unrunnable, 0 runnable, >0 stopped */
268 unsigned long flags
; /* per process flags, defined below */
270 mm_segment_t addr_limit
; /* thread address space:
271 0-0xBFFFFFFF for user-thead
272 0-0xFFFFFFFF for kernel-thread
274 struct exec_domain
*exec_domain
;
275 volatile long need_resched
;
281 /* SMP and runqueue state */
285 int lock_depth
; /* Lock depth. We can context switch in and out of holding a syscall kernel lock... */
286 struct task_struct
*next_task
, *prev_task
;
287 struct list_head run_list
;
290 struct linux_binfmt
*binfmt
;
291 int exit_code
, exit_signal
;
292 int pdeath_signal
; /* The signal sent when the parent dies */
294 unsigned long personality
;
301 /* boolean value for session group leader */
304 * pointers to (original) parent process, youngest child, younger sibling,
305 * older sibling, respectively. (p->father can be replaced with
308 struct task_struct
*p_opptr
, *p_pptr
, *p_cptr
, *p_ysptr
, *p_osptr
;
310 /* PID hash table linkage. */
311 struct task_struct
*pidhash_next
;
312 struct task_struct
**pidhash_pprev
;
314 wait_queue_head_t wait_chldexit
; /* for wait4() */
315 struct semaphore
*vfork_sem
; /* for vfork() */
316 unsigned long policy
, rt_priority
;
317 unsigned long it_real_value
, it_prof_value
, it_virt_value
;
318 unsigned long it_real_incr
, it_prof_incr
, it_virt_incr
;
319 struct timer_list real_timer
;
321 unsigned long start_time
;
322 long per_cpu_utime
[NR_CPUS
], per_cpu_stime
[NR_CPUS
];
323 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
324 unsigned long min_flt
, maj_flt
, nswap
, cmin_flt
, cmaj_flt
, cnswap
;
326 /* process credentials */
327 uid_t uid
,euid
,suid
,fsuid
;
328 gid_t gid
,egid
,sgid
,fsgid
;
330 gid_t groups
[NGROUPS
];
331 kernel_cap_t cap_effective
, cap_inheritable
, cap_permitted
;
332 struct user_struct
*user
;
334 struct rlimit rlim
[RLIM_NLIMITS
];
335 unsigned short used_math
;
337 /* file system info */
339 struct tty_struct
*tty
; /* NULL if no tty */
341 struct sem_undo
*semundo
;
342 struct sem_queue
*semsleeping
;
343 /* CPU-specific state of this task */
344 struct thread_struct thread
;
345 /* filesystem information */
346 struct fs_struct
*fs
;
347 /* open file information */
348 struct files_struct
*files
;
350 /* memory management info */
351 struct mm_struct
*mm
, *active_mm
;
353 /* signal handlers */
354 spinlock_t sigmask_lock
; /* Protects signal and blocked */
355 struct signal_struct
*sig
;
356 sigset_t signal
, blocked
;
357 struct signal_queue
*sigqueue
, **sigqueue_tail
;
358 unsigned long sas_ss_sp
;
361 /* Thread group tracking */
369 #define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */
370 /* Not implemented yet, only for 486*/
371 #define PF_STARTING 0x00000002 /* being created */
372 #define PF_EXITING 0x00000004 /* getting shut down */
373 #define PF_PTRACED 0x00000010 /* set if ptrace (0) has been called */
374 #define PF_TRACESYS 0x00000020 /* tracing system calls */
375 #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */
376 #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */
377 #define PF_DUMPCORE 0x00000200 /* dumped core */
378 #define PF_SIGNALED 0x00000400 /* killed by a signal */
379 #define PF_MEMALLOC 0x00000800 /* Allocating memory */
380 #define PF_VFORK 0x00001000 /* Wake up parent in mm_release */
382 #define PF_USEDFPU 0x00100000 /* task used FPU this quantum (SMP) */
383 #define PF_DTRACE 0x00200000 /* delayed trace (used on m68k, i386) */
386 * Limit the stack by to some sane default: root can always
387 * increase this limit if needed.. 8MB seems reasonable.
389 #define _STK_LIM (8*1024*1024)
391 #define DEF_PRIORITY (20*HZ/100) /* 200 ms time slices */
394 * INIT_TASK is used to set up the first task table, touch at
395 * your own risk!. Base=0, limit=0x1fffff (=2MB)
397 #define INIT_TASK(name) \
398 /* state etc */ { 0,0,0,KERNEL_DS,&default_exec_domain,0, \
399 /* counter */ DEF_PRIORITY,DEF_PRIORITY,0, \
400 /* SMP */ 0,0,0,-1, \
401 /* schedlink */ &init_task,&init_task, LIST_HEAD_INIT(init_task.run_list), \
403 /* ec,brk... */ 0,0,0,0,0,0, \
404 /* pid etc.. */ 0,0,0,0,0, \
405 /* proc links*/ &init_task,&init_task,NULL,NULL,NULL, \
406 /* pidhash */ NULL, NULL, \
407 /* chld wait */ __WAIT_QUEUE_HEAD_INITIALIZER(name.wait_chldexit), NULL, \
408 /* timeout */ SCHED_OTHER,0,0,0,0,0,0,0, \
409 /* timer */ { NULL, NULL, 0, 0, it_real_fn }, \
410 /* utime */ {0,0,0,0},0, \
411 /* per CPU times */ {0, }, {0, }, \
412 /* flt */ 0,0,0,0,0,0, \
414 /* process credentials */ \
415 /* uid etc */ 0,0,0,0,0,0,0,0, \
416 /* suppl grps*/ 0, {0,}, \
417 /* caps */ CAP_INIT_EFF_SET,CAP_INIT_INH_SET,CAP_FULL_SET, \
419 /* rlimits */ INIT_RLIMITS, \
421 /* comm */ "swapper", \
422 /* fs info */ 0,NULL, \
423 /* ipc */ NULL, NULL, \
424 /* thread */ INIT_THREAD, \
426 /* files */ &init_files, \
427 /* mm */ NULL, &init_mm, \
428 /* signals */ SPIN_LOCK_UNLOCKED, &init_signals, {{0}}, {{0}}, NULL, &init_task.sigqueue, 0, 0, \
429 /* exec cts */ 0,0, \
432 #ifndef INIT_TASK_SIZE
433 # define INIT_TASK_SIZE 2048*sizeof(long)
437 struct task_struct task
;
438 unsigned long stack
[INIT_TASK_SIZE
/sizeof(long)];
441 extern union task_union init_task_union
;
443 extern struct mm_struct init_mm
;
444 extern struct task_struct
*init_tasks
[NR_CPUS
];
446 /* PID hashing. (shouldnt this be dynamic?) */
447 #define PIDHASH_SZ (4096 >> 2)
448 extern struct task_struct
*pidhash
[PIDHASH_SZ
];
450 #define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
452 extern __inline__
void hash_pid(struct task_struct
*p
)
454 struct task_struct
**htable
= &pidhash
[pid_hashfn(p
->pid
)];
456 if((p
->pidhash_next
= *htable
) != NULL
)
457 (*htable
)->pidhash_pprev
= &p
->pidhash_next
;
459 p
->pidhash_pprev
= htable
;
462 extern __inline__
void unhash_pid(struct task_struct
*p
)
465 p
->pidhash_next
->pidhash_pprev
= p
->pidhash_pprev
;
466 *p
->pidhash_pprev
= p
->pidhash_next
;
469 extern __inline__
struct task_struct
*find_task_by_pid(int pid
)
471 struct task_struct
*p
, **htable
= &pidhash
[pid_hashfn(pid
)];
473 for(p
= *htable
; p
&& p
->pid
!= pid
; p
= p
->pidhash_next
)
479 /* per-UID process charging. */
480 extern int alloc_uid(struct task_struct
*);
481 void free_uid(struct task_struct
*);
483 #include <asm/current.h>
485 extern unsigned long volatile jiffies
;
486 extern unsigned long itimer_ticks
;
487 extern unsigned long itimer_next
;
488 extern struct timeval xtime
;
489 extern void do_timer(struct pt_regs
*);
491 extern unsigned int * prof_buffer
;
492 extern unsigned long prof_len
;
493 extern unsigned long prof_shift
;
495 #define CURRENT_TIME (xtime.tv_sec)
497 extern void FASTCALL(__wake_up(wait_queue_head_t
*q
, unsigned int mode
));
498 extern void FASTCALL(sleep_on(wait_queue_head_t
*q
));
499 extern long FASTCALL(sleep_on_timeout(wait_queue_head_t
*q
,
500 signed long timeout
));
501 extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t
*q
));
502 extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t
*q
,
503 signed long timeout
));
504 extern void FASTCALL(wake_up_process(struct task_struct
* tsk
));
506 #define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
507 #define wake_up_interruptible(x) __wake_up((x),TASK_INTERRUPTIBLE)
509 extern int in_group_p(gid_t
);
511 extern void flush_signals(struct task_struct
*);
512 extern void flush_signal_handlers(struct task_struct
*);
513 extern int dequeue_signal(sigset_t
*, siginfo_t
*);
514 extern int send_sig_info(int, struct siginfo
*, struct task_struct
*);
515 extern int force_sig_info(int, struct siginfo
*, struct task_struct
*);
516 extern int kill_pg_info(int, struct siginfo
*, pid_t
);
517 extern int kill_sl_info(int, struct siginfo
*, pid_t
);
518 extern int kill_proc_info(int, struct siginfo
*, pid_t
);
519 extern int kill_something_info(int, struct siginfo
*, int);
520 extern void notify_parent(struct task_struct
*, int);
521 extern void force_sig(int, struct task_struct
*);
522 extern int send_sig(int, struct task_struct
*, int);
523 extern int kill_pg(pid_t
, int, int);
524 extern int kill_sl(pid_t
, int, int);
525 extern int kill_proc(pid_t
, int, int);
526 extern int do_sigaction(int, const struct k_sigaction
*, struct k_sigaction
*);
527 extern int do_sigaltstack(const stack_t
*, stack_t
*, unsigned long);
529 extern inline int signal_pending(struct task_struct
*p
)
531 return (p
->sigpending
!= 0);
534 /* Reevaluate whether the task has signals pending delivery.
535 This is required every time the blocked sigset_t changes.
536 All callers should have t->sigmask_lock. */
538 static inline void recalc_sigpending(struct task_struct
*t
)
543 switch (_NSIG_WORDS
) {
545 for (i
= _NSIG_WORDS
, ready
= 0; --i
>= 0 ;)
546 ready
|= t
->signal
.sig
[i
] &~ t
->blocked
.sig
[i
];
549 case 4: ready
= t
->signal
.sig
[3] &~ t
->blocked
.sig
[3];
550 ready
|= t
->signal
.sig
[2] &~ t
->blocked
.sig
[2];
551 ready
|= t
->signal
.sig
[1] &~ t
->blocked
.sig
[1];
552 ready
|= t
->signal
.sig
[0] &~ t
->blocked
.sig
[0];
555 case 2: ready
= t
->signal
.sig
[1] &~ t
->blocked
.sig
[1];
556 ready
|= t
->signal
.sig
[0] &~ t
->blocked
.sig
[0];
559 case 1: ready
= t
->signal
.sig
[0] &~ t
->blocked
.sig
[0];
562 t
->sigpending
= (ready
!= 0);
565 /* True if we are on the alternate signal stack. */
567 static inline int on_sig_stack(unsigned long sp
)
569 return (sp
- current
->sas_ss_sp
< current
->sas_ss_size
);
572 static inline int sas_ss_flags(unsigned long sp
)
574 return (current
->sas_ss_size
== 0 ? SS_DISABLE
575 : on_sig_stack(sp
) ? SS_ONSTACK
: 0);
578 extern int request_irq(unsigned int,
579 void (*handler
)(int, void *, struct pt_regs
*),
580 unsigned long, const char *, void *);
581 extern void free_irq(unsigned int, void *);
584 * This has now become a routine instead of a macro, it sets a flag if
585 * it returns true (to do BSD-style accounting where the process is flagged
586 * if it uses root privs). The implication of this is that you should do
587 * normal permissions checks first, and check suser() last.
589 * [Dec 1997 -- Chris Evans]
590 * For correctness, the above considerations need to be extended to
591 * fsuser(). This is done, along with moving fsuser() checks to be
594 * These will be removed, but in the mean time, when the SECURE_NOROOT
595 * flag is set, uids don't grant privilege.
597 extern inline int suser(void)
599 if (!issecure(SECURE_NOROOT
) && current
->euid
== 0) {
600 current
->flags
|= PF_SUPERPRIV
;
606 extern inline int fsuser(void)
608 if (!issecure(SECURE_NOROOT
) && current
->fsuid
== 0) {
609 current
->flags
|= PF_SUPERPRIV
;
616 * capable() checks for a particular capability.
617 * New privilege checks should use this interface, rather than suser() or
618 * fsuser(). See include/linux/capability.h for defined capabilities.
621 extern inline int capable(int cap
)
624 if (cap_raised(current
->cap_effective
, cap
))
626 if (cap_is_fs_cap(cap
) ? current
->fsuid
== 0 : current
->euid
== 0)
629 current
->flags
|= PF_SUPERPRIV
;
636 * Routines for handling mm_structs
638 extern struct mm_struct
* mm_alloc(void);
640 extern struct mm_struct
* start_lazy_tlb(void);
641 extern void end_lazy_tlb(struct mm_struct
*mm
);
643 /* mmdrop drops the mm and the page tables */
644 extern inline void FASTCALL(__mmdrop(struct mm_struct
*));
645 static inline void mmdrop(struct mm_struct
* mm
)
647 if (atomic_dec_and_test(&mm
->mm_count
))
651 /* mmput gets rid of the mappings and all user-space */
652 extern void mmput(struct mm_struct
*);
653 /* Remove the current tasks stale references to the old mm_struct */
654 extern void mm_release(void);
657 * Routines for handling the fd arrays
659 extern struct file
** alloc_fd_array(int);
660 extern int expand_fd_array(struct files_struct
*, int nr
);
661 extern void free_fd_array(struct file
**, int);
663 extern fd_set
*alloc_fdset(int);
664 extern int expand_fdset(struct files_struct
*, int nr
);
665 extern void free_fdset(fd_set
*, int);
667 /* Expand files. Return <0 on error; 0 nothing done; 1 files expanded,
668 * we may have blocked.
670 * Should be called with the files->file_lock spinlock held for write.
672 static inline int expand_files(struct files_struct
*files
, int nr
)
676 printk (KERN_ERR __FUNCTION__
" %d: nr = %d\n", current
->pid
, nr
);
679 if (nr
>= files
->max_fdset
) {
681 if ((err
= expand_fdset(files
, nr
)))
684 if (nr
>= files
->max_fds
) {
686 if ((err
= expand_fd_array(files
, nr
)))
693 printk (KERN_ERR __FUNCTION__
" %d: return %d\n", current
->pid
, err
);
698 extern int copy_thread(int, unsigned long, unsigned long, struct task_struct
*, struct pt_regs
*);
699 extern void flush_thread(void);
700 extern void exit_thread(void);
702 extern void exit_mm(struct task_struct
*);
703 extern void exit_fs(struct task_struct
*);
704 extern void exit_files(struct task_struct
*);
705 extern void exit_sighand(struct task_struct
*);
707 extern void daemonize(void);
709 extern int do_execve(char *, char **, char **, struct pt_regs
*);
710 extern int do_fork(unsigned long, unsigned long, struct pt_regs
*);
712 extern inline void add_wait_queue(wait_queue_head_t
*q
, wait_queue_t
* wait
)
716 wq_write_lock_irqsave(&q
->lock
, flags
);
717 __add_wait_queue(q
, wait
);
718 wq_write_unlock_irqrestore(&q
->lock
, flags
);
721 extern inline void add_wait_queue_exclusive(wait_queue_head_t
*q
,
726 wq_write_lock_irqsave(&q
->lock
, flags
);
727 __add_wait_queue_tail(q
, wait
);
728 wq_write_unlock_irqrestore(&q
->lock
, flags
);
731 extern inline void remove_wait_queue(wait_queue_head_t
*q
, wait_queue_t
* wait
)
735 wq_write_lock_irqsave(&q
->lock
, flags
);
736 __remove_wait_queue(q
, wait
);
737 wq_write_unlock_irqrestore(&q
->lock
, flags
);
740 #define __wait_event(wq, condition) \
742 wait_queue_t __wait; \
743 init_waitqueue_entry(&__wait, current); \
745 add_wait_queue(&wq, &__wait); \
747 set_current_state(TASK_UNINTERRUPTIBLE); \
752 current->state = TASK_RUNNING; \
753 remove_wait_queue(&wq, &__wait); \
756 #define wait_event(wq, condition) \
760 __wait_event(wq, condition); \
763 #define __wait_event_interruptible(wq, condition, ret) \
765 wait_queue_t __wait; \
766 init_waitqueue_entry(&__wait, current); \
768 add_wait_queue(&wq, &__wait); \
770 set_current_state(TASK_INTERRUPTIBLE); \
773 if (!signal_pending(current)) { \
777 ret = -ERESTARTSYS; \
780 current->state = TASK_RUNNING; \
781 remove_wait_queue(&wq, &__wait); \
784 #define wait_event_interruptible(wq, condition) \
788 __wait_event_interruptible(wq, condition, __ret); \
792 #define REMOVE_LINKS(p) do { \
793 (p)->next_task->prev_task = (p)->prev_task; \
794 (p)->prev_task->next_task = (p)->next_task; \
796 (p)->p_osptr->p_ysptr = (p)->p_ysptr; \
798 (p)->p_ysptr->p_osptr = (p)->p_osptr; \
800 (p)->p_pptr->p_cptr = (p)->p_osptr; \
803 #define SET_LINKS(p) do { \
804 (p)->next_task = &init_task; \
805 (p)->prev_task = init_task.prev_task; \
806 init_task.prev_task->next_task = (p); \
807 init_task.prev_task = (p); \
808 (p)->p_ysptr = NULL; \
809 if (((p)->p_osptr = (p)->p_pptr->p_cptr) != NULL) \
810 (p)->p_osptr->p_ysptr = p; \
811 (p)->p_pptr->p_cptr = p; \
814 #define for_each_task(p) \
815 for (p = &init_task ; (p = p->next_task) != &init_task ; )
818 static inline void del_from_runqueue(struct task_struct
* p
)
821 list_del(&p
->run_list
);
822 p
->run_list
.next
= NULL
;
825 extern inline int task_on_runqueue(struct task_struct
*p
)
827 return (p
->run_list
.next
!= NULL
);
830 extern inline void unhash_process(struct task_struct
*p
)
832 if (task_on_runqueue(p
)) BUG();
833 write_lock_irq(&tasklist_lock
);
837 write_unlock_irq(&tasklist_lock
);
840 #endif /* __KERNEL__ */