Import 2.3.10pre1
[davej-history.git] / include / linux / sched.h
blob251aa8f9d205a795ed0082ca23615dff65933356
1 #ifndef _LINUX_SCHED_H
2 #define _LINUX_SCHED_H
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/tasks.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>
18 #include <asm/page.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>
28 * cloning flags:
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 */
40 * These are the constant used to fake the fixed-point load-average
41 * counting. Some notes:
42 * - 11 bit fractions expand to 22 bits by the multiplies: this gives
43 * a load-average precision of 10 bits integer + 11 bits fractional
44 * - if you want to count load-averages more often, you need more
45 * precision, or rounding will get you. With 2-second counting freq,
46 * the EXP_n values would be 1981, 2034 and 2043 if still using only
47 * 11 bit fractions.
49 extern unsigned long avenrun[]; /* Load averages */
51 #define FSHIFT 11 /* nr of bits of precision */
52 #define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
53 #define LOAD_FREQ (5*HZ) /* 5 sec intervals */
54 #define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
55 #define EXP_5 2014 /* 1/exp(5sec/5min) */
56 #define EXP_15 2037 /* 1/exp(5sec/15min) */
58 #define CALC_LOAD(load,exp,n) \
59 load *= exp; \
60 load += n*(FIXED_1-exp); \
61 load >>= FSHIFT;
63 #define CT_TO_SECS(x) ((x) / HZ)
64 #define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ)
66 extern int nr_running, nr_tasks;
67 extern int last_pid;
69 #include <linux/fs.h>
70 #include <linux/time.h>
71 #include <linux/param.h>
72 #include <linux/resource.h>
73 #include <linux/timer.h>
75 #include <asm/processor.h>
77 #define TASK_RUNNING 0
78 #define TASK_INTERRUPTIBLE 1
79 #define TASK_UNINTERRUPTIBLE 2
80 #define TASK_ZOMBIE 4
81 #define TASK_STOPPED 8
82 #define TASK_SWAPPING 16
83 #define TASK_EXCLUSIVE 32
86 * Scheduling policies
88 #define SCHED_OTHER 0
89 #define SCHED_FIFO 1
90 #define SCHED_RR 2
93 * This is an additional bit set when we want to
94 * yield the CPU for one re-schedule..
96 #define SCHED_YIELD 0x10
98 struct sched_param {
99 int sched_priority;
102 #ifndef NULL
103 #define NULL ((void *) 0)
104 #endif
106 #ifdef __KERNEL__
108 #include <asm/spinlock.h>
111 * This serializes "schedule()" and also protects
112 * the run-queue from deletions/modifications (but
113 * _adding_ to the beginning of the run-queue has
114 * a separate lock).
116 extern rwlock_t tasklist_lock;
117 extern spinlock_t runqueue_lock;
119 extern void sched_init(void);
120 extern void init_idle(void);
121 extern void show_state(void);
122 extern void trap_init(void);
124 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
125 extern signed long FASTCALL(schedule_timeout(signed long timeout));
126 asmlinkage void schedule(void);
129 * Open file table structure
131 struct files_struct {
132 atomic_t count;
133 rwlock_t file_lock;
134 int max_fds;
135 struct file ** fd; /* current fd array */
136 fd_set close_on_exec;
137 fd_set open_fds;
140 #define INIT_FILES { \
141 ATOMIC_INIT(1), \
142 RW_LOCK_UNLOCKED, \
143 NR_OPEN, \
144 &init_fd_array[0], \
145 { { 0, } }, \
146 { { 0, } } \
149 struct fs_struct {
150 atomic_t count;
151 int umask;
152 struct dentry * root, * pwd;
155 #define INIT_FS { \
156 ATOMIC_INIT(1), \
157 0022, \
158 NULL, NULL \
161 /* Maximum number of active map areas.. This is a random (large) number */
162 #define MAX_MAP_COUNT (65536)
164 /* Number of map areas at which the AVL tree is activated. This is arbitrary. */
165 #define AVL_MIN_MAP_COUNT 32
167 struct mm_struct {
168 struct vm_area_struct * mmap; /* list of VMAs */
169 struct vm_area_struct * mmap_avl; /* tree of VMAs */
170 struct vm_area_struct * mmap_cache; /* last find_vma result */
171 pgd_t * pgd;
172 atomic_t count;
173 int map_count; /* number of VMAs */
174 struct semaphore mmap_sem;
175 rwlock_t page_table_lock;
176 unsigned long context;
177 unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
178 int swappable:1;
179 unsigned long start_code, end_code, start_data, end_data;
180 unsigned long start_brk, brk, start_stack;
181 unsigned long arg_start, arg_end, env_start, env_end;
182 unsigned long rss, total_vm, locked_vm;
183 unsigned long def_flags;
184 unsigned long cpu_vm_mask;
185 unsigned long swap_cnt; /* number of pages to swap on next pass */
186 unsigned long swap_address;
188 * This is an architecture-specific pointer: the portable
189 * part of Linux does not know about any segments.
191 void * segments;
194 #define INIT_MM(name) { \
195 &init_mmap, NULL, NULL, \
196 swapper_pg_dir, \
197 ATOMIC_INIT(1), 1, \
198 __MUTEX_INITIALIZER(name.mmap_sem), \
199 RW_LOCK_UNLOCKED, \
200 0, \
201 0, 0, 0, 0, 0, 0, \
202 0, \
203 0, 0, 0, 0, \
204 0, 0, 0, \
205 0, 0, 0, 0, \
206 0, 0, 0, \
207 0, 0, 0, 0, NULL }
209 struct signal_struct {
210 atomic_t count;
211 struct k_sigaction action[_NSIG];
212 spinlock_t siglock;
216 #define INIT_SIGNALS { \
217 ATOMIC_INIT(1), \
218 { {{0,}}, }, \
219 SPIN_LOCK_UNLOCKED }
222 * Some day this will be a full-fledged user tracking system..
223 * Right now it is only used to track how many processes a
224 * user has, but it has the potential to track memory usage etc.
226 struct user_struct;
228 struct task_struct {
229 /* these are hardcoded - don't touch */
230 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
231 unsigned long flags; /* per process flags, defined below */
232 int sigpending;
233 mm_segment_t addr_limit; /* thread address space:
234 0-0xBFFFFFFF for user-thead
235 0-0xFFFFFFFF for kernel-thread
237 struct exec_domain *exec_domain;
238 long need_resched;
240 /* various fields */
241 long counter;
242 long priority;
243 cycles_t avg_slice;
244 /* SMP and runqueue state */
245 int has_cpu;
246 int processor;
247 int last_processor;
248 int lock_depth; /* Lock depth. We can context switch in and out of holding a syscall kernel lock... */
249 struct task_struct *next_task, *prev_task;
250 struct task_struct *next_run, *prev_run;
252 /* task state */
253 struct linux_binfmt *binfmt;
254 int exit_code, exit_signal;
255 int pdeath_signal; /* The signal sent when the parent dies */
256 /* ??? */
257 unsigned long personality;
258 int dumpable:1;
259 int did_exec:1;
260 pid_t pid;
261 pid_t pgrp;
262 pid_t tty_old_pgrp;
263 pid_t session;
264 /* boolean value for session group leader */
265 int leader;
267 * pointers to (original) parent process, youngest child, younger sibling,
268 * older sibling, respectively. (p->father can be replaced with
269 * p->p_pptr->pid)
271 struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr;
273 /* PID hash table linkage. */
274 struct task_struct *pidhash_next;
275 struct task_struct **pidhash_pprev;
277 /* Pointer to task[] array linkage. */
278 struct task_struct **tarray_ptr;
280 wait_queue_head_t wait_chldexit; /* for wait4() */
281 struct semaphore *vfork_sem; /* for vfork() */
282 unsigned long policy, rt_priority;
283 unsigned long it_real_value, it_prof_value, it_virt_value;
284 unsigned long it_real_incr, it_prof_incr, it_virt_incr;
285 struct timer_list real_timer;
286 struct tms times;
287 unsigned long start_time;
288 long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS];
289 /* process credentials */
290 uid_t uid,euid,suid,fsuid;
291 gid_t gid,egid,sgid,fsgid;
292 int ngroups;
293 gid_t groups[NGROUPS];
294 kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
295 struct user_struct *user;
296 /* limits */
297 struct rlimit rlim[RLIM_NLIMITS];
298 unsigned short used_math;
299 char comm[16];
300 /* file system info */
301 int link_count;
302 struct tty_struct *tty; /* NULL if no tty */
303 /* ipc stuff */
304 struct sem_undo *semundo;
305 struct sem_queue *semsleeping;
306 /* tss for this task */
307 struct thread_struct tss;
308 /* filesystem information */
309 struct fs_struct *fs;
310 /* open file information */
311 struct files_struct *files;
312 /* memory management info */
313 struct mm_struct *mm;
315 /* signal handlers */
316 spinlock_t sigmask_lock; /* Protects signal and blocked */
317 struct signal_struct *sig;
318 sigset_t signal, blocked;
319 struct signal_queue *sigqueue, **sigqueue_tail;
320 unsigned long sas_ss_sp;
321 size_t sas_ss_size;
325 * Per process flags
327 #define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */
328 /* Not implemented yet, only for 486*/
329 #define PF_STARTING 0x00000002 /* being created */
330 #define PF_EXITING 0x00000004 /* getting shut down */
331 #define PF_PTRACED 0x00000010 /* set if ptrace (0) has been called */
332 #define PF_TRACESYS 0x00000020 /* tracing system calls */
333 #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */
334 #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */
335 #define PF_DUMPCORE 0x00000200 /* dumped core */
336 #define PF_SIGNALED 0x00000400 /* killed by a signal */
337 #define PF_MEMALLOC 0x00000800 /* Allocating memory */
338 #define PF_VFORK 0x00001000 /* Wake up parent in mm_release */
340 #define PF_USEDFPU 0x00100000 /* task used FPU this quantum (SMP) */
341 #define PF_DTRACE 0x00200000 /* delayed trace (used on m68k, i386) */
344 * Limit the stack by to some sane default: root can always
345 * increase this limit if needed.. 8MB seems reasonable.
347 #define _STK_LIM (8*1024*1024)
349 #define DEF_PRIORITY (20*HZ/100) /* 200 ms time slices */
352 * INIT_TASK is used to set up the first task table, touch at
353 * your own risk!. Base=0, limit=0x1fffff (=2MB)
355 #define INIT_TASK(name) \
356 /* state etc */ { 0,0,0,KERNEL_DS,&default_exec_domain,0, \
357 /* counter */ DEF_PRIORITY,DEF_PRIORITY,0, \
358 /* SMP */ 0,0,0,-1, \
359 /* schedlink */ &init_task,&init_task, &init_task, &init_task, \
360 /* binfmt */ NULL, \
361 /* ec,brk... */ 0,0,0,0,0,0, \
362 /* pid etc.. */ 0,0,0,0,0, \
363 /* proc links*/ &init_task,&init_task,NULL,NULL,NULL, \
364 /* pidhash */ NULL, NULL, \
365 /* tarray */ &task[0], \
366 /* chld wait */ __WAIT_QUEUE_HEAD_INITIALIZER(name.wait_chldexit), NULL, \
367 /* timeout */ SCHED_OTHER,0,0,0,0,0,0,0, \
368 /* timer */ { NULL, NULL, 0, 0, it_real_fn }, \
369 /* utime */ {0,0,0,0},0, \
370 /* per CPU times */ {0, }, {0, }, \
371 /* process credentials */ \
372 /* uid etc */ 0,0,0,0,0,0,0,0, \
373 /* suppl grps*/ 0, {0,}, \
374 /* caps */ CAP_INIT_EFF_SET,CAP_INIT_INH_SET,CAP_FULL_SET, \
375 /* user */ NULL, \
376 /* rlimits */ INIT_RLIMITS, \
377 /* math */ 0, \
378 /* comm */ "swapper", \
379 /* fs info */ 0,NULL, \
380 /* ipc */ NULL, NULL, \
381 /* tss */ INIT_TSS, \
382 /* fs */ &init_fs, \
383 /* files */ &init_files, \
384 /* mm */ &init_mm, \
385 /* signals */ SPIN_LOCK_UNLOCKED, &init_signals, {{0}}, {{0}}, NULL, &init_task.sigqueue, 0, 0, \
388 #ifndef INIT_TASK_SIZE
389 # define INIT_TASK_SIZE 2048*sizeof(long)
390 #endif
392 union task_union {
393 struct task_struct task;
394 unsigned long stack[INIT_TASK_SIZE/sizeof(long)];
397 extern union task_union init_task_union;
399 extern struct mm_struct init_mm;
400 extern struct task_struct *task[NR_TASKS];
402 extern struct task_struct **tarray_freelist;
403 extern spinlock_t taskslot_lock;
405 extern __inline__ void add_free_taskslot(struct task_struct **t)
407 spin_lock(&taskslot_lock);
408 *t = (struct task_struct *) tarray_freelist;
409 tarray_freelist = t;
410 spin_unlock(&taskslot_lock);
413 extern __inline__ struct task_struct **get_free_taskslot(void)
415 struct task_struct **tslot;
417 spin_lock(&taskslot_lock);
418 if((tslot = tarray_freelist) != NULL)
419 tarray_freelist = (struct task_struct **) *tslot;
420 spin_unlock(&taskslot_lock);
422 return tslot;
425 /* PID hashing. */
426 #define PIDHASH_SZ (NR_TASKS >> 2)
427 extern struct task_struct *pidhash[PIDHASH_SZ];
429 #define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
431 extern __inline__ void hash_pid(struct task_struct *p)
433 struct task_struct **htable = &pidhash[pid_hashfn(p->pid)];
435 if((p->pidhash_next = *htable) != NULL)
436 (*htable)->pidhash_pprev = &p->pidhash_next;
437 *htable = p;
438 p->pidhash_pprev = htable;
441 extern __inline__ void unhash_pid(struct task_struct *p)
443 if(p->pidhash_next)
444 p->pidhash_next->pidhash_pprev = p->pidhash_pprev;
445 *p->pidhash_pprev = p->pidhash_next;
448 extern __inline__ struct task_struct *find_task_by_pid(int pid)
450 struct task_struct *p, **htable = &pidhash[pid_hashfn(pid)];
452 for(p = *htable; p && p->pid != pid; p = p->pidhash_next)
455 return p;
458 /* per-UID process charging. */
459 extern int alloc_uid(struct task_struct *);
460 void free_uid(struct task_struct *);
462 #include <asm/current.h>
464 extern unsigned long volatile jiffies;
465 extern unsigned long itimer_ticks;
466 extern unsigned long itimer_next;
467 extern struct timeval xtime;
468 extern void do_timer(struct pt_regs *);
470 extern unsigned int * prof_buffer;
471 extern unsigned long prof_len;
472 extern unsigned long prof_shift;
474 #define CURRENT_TIME (xtime.tv_sec)
476 extern void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode));
477 extern void FASTCALL(sleep_on(wait_queue_head_t *q));
478 extern long FASTCALL(sleep_on_timeout(wait_queue_head_t *q,
479 signed long timeout));
480 extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q));
481 extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q,
482 signed long timeout));
483 extern void FASTCALL(wake_up_process(struct task_struct * tsk));
485 #define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
486 #define wake_up_interruptible(x) __wake_up((x),TASK_INTERRUPTIBLE)
488 extern int in_group_p(gid_t);
490 extern void flush_signals(struct task_struct *);
491 extern void flush_signal_handlers(struct task_struct *);
492 extern int dequeue_signal(sigset_t *, siginfo_t *);
493 extern int send_sig_info(int, struct siginfo *, struct task_struct *);
494 extern int force_sig_info(int, struct siginfo *, struct task_struct *);
495 extern int kill_pg_info(int, struct siginfo *, pid_t);
496 extern int kill_sl_info(int, struct siginfo *, pid_t);
497 extern int kill_proc_info(int, struct siginfo *, pid_t);
498 extern int kill_something_info(int, struct siginfo *, int);
499 extern void notify_parent(struct task_struct *, int);
500 extern void force_sig(int, struct task_struct *);
501 extern int send_sig(int, struct task_struct *, int);
502 extern int kill_pg(pid_t, int, int);
503 extern int kill_sl(pid_t, int, int);
504 extern int kill_proc(pid_t, int, int);
505 extern int do_sigaction(int, const struct k_sigaction *, struct k_sigaction *);
506 extern int do_sigaltstack(const stack_t *, stack_t *, unsigned long);
508 extern inline int signal_pending(struct task_struct *p)
510 return (p->sigpending != 0);
513 /* Reevaluate whether the task has signals pending delivery.
514 This is required every time the blocked sigset_t changes.
515 All callers should have t->sigmask_lock. */
517 static inline void recalc_sigpending(struct task_struct *t)
519 unsigned long ready;
520 long i;
522 switch (_NSIG_WORDS) {
523 default:
524 for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;)
525 ready |= t->signal.sig[i] &~ t->blocked.sig[i];
526 break;
528 case 4: ready = t->signal.sig[3] &~ t->blocked.sig[3];
529 ready |= t->signal.sig[2] &~ t->blocked.sig[2];
530 ready |= t->signal.sig[1] &~ t->blocked.sig[1];
531 ready |= t->signal.sig[0] &~ t->blocked.sig[0];
532 break;
534 case 2: ready = t->signal.sig[1] &~ t->blocked.sig[1];
535 ready |= t->signal.sig[0] &~ t->blocked.sig[0];
536 break;
538 case 1: ready = t->signal.sig[0] &~ t->blocked.sig[0];
541 t->sigpending = (ready != 0);
544 /* True if we are on the alternate signal stack. */
546 static inline int on_sig_stack(unsigned long sp)
548 return (sp - current->sas_ss_sp < current->sas_ss_size);
551 static inline int sas_ss_flags(unsigned long sp)
553 return (current->sas_ss_size == 0 ? SS_DISABLE
554 : on_sig_stack(sp) ? SS_ONSTACK : 0);
557 extern int request_irq(unsigned int,
558 void (*handler)(int, void *, struct pt_regs *),
559 unsigned long, const char *, void *);
560 extern void free_irq(unsigned int, void *);
563 * This has now become a routine instead of a macro, it sets a flag if
564 * it returns true (to do BSD-style accounting where the process is flagged
565 * if it uses root privs). The implication of this is that you should do
566 * normal permissions checks first, and check suser() last.
568 * [Dec 1997 -- Chris Evans]
569 * For correctness, the above considerations need to be extended to
570 * fsuser(). This is done, along with moving fsuser() checks to be
571 * last.
573 * These will be removed, but in the mean time, when the SECURE_NOROOT
574 * flag is set, uids don't grant privilege.
576 extern inline int suser(void)
578 if (!issecure(SECURE_NOROOT) && current->euid == 0) {
579 current->flags |= PF_SUPERPRIV;
580 return 1;
582 return 0;
585 extern inline int fsuser(void)
587 if (!issecure(SECURE_NOROOT) && current->fsuid == 0) {
588 current->flags |= PF_SUPERPRIV;
589 return 1;
591 return 0;
595 * capable() checks for a particular capability.
596 * New privilege checks should use this interface, rather than suser() or
597 * fsuser(). See include/linux/capability.h for defined capabilities.
600 extern inline int capable(int cap)
602 #if 1 /* ok now */
603 if (cap_raised(current->cap_effective, cap))
604 #else
605 if (cap_is_fs_cap(cap) ? current->fsuid == 0 : current->euid == 0)
606 #endif
608 current->flags |= PF_SUPERPRIV;
609 return 1;
611 return 0;
615 * Routines for handling mm_structs
617 extern struct mm_struct * mm_alloc(void);
618 static inline void mmget(struct mm_struct * mm)
620 atomic_inc(&mm->count);
622 extern void mmput(struct mm_struct *);
623 /* Remove the current tasks stale references to the old mm_struct */
624 extern void mm_release(void);
626 extern int copy_thread(int, unsigned long, unsigned long, struct task_struct *, struct pt_regs *);
627 extern void flush_thread(void);
628 extern void exit_thread(void);
630 extern void exit_mm(struct task_struct *);
631 extern void exit_fs(struct task_struct *);
632 extern void exit_files(struct task_struct *);
633 extern void exit_sighand(struct task_struct *);
635 extern int do_execve(char *, char **, char **, struct pt_regs *);
636 extern int do_fork(unsigned long, unsigned long, struct pt_regs *);
638 extern inline void add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)
640 unsigned long flags;
642 wq_write_lock_irqsave(&q->lock, flags);
643 __add_wait_queue(q, wait);
644 wq_write_unlock_irqrestore(&q->lock, flags);
647 extern inline void add_wait_queue_exclusive(wait_queue_head_t *q,
648 wait_queue_t * wait)
650 unsigned long flags;
652 wq_write_lock_irqsave(&q->lock, flags);
653 __add_wait_queue_tail(q, wait);
654 wq_write_unlock_irqrestore(&q->lock, flags);
657 extern inline void remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait)
659 unsigned long flags;
661 wq_write_lock_irqsave(&q->lock, flags);
662 __remove_wait_queue(q, wait);
663 wq_write_unlock_irqrestore(&q->lock, flags);
666 #define __wait_event(wq, condition) \
667 do { \
668 wait_queue_t __wait; \
669 init_waitqueue_entry(&__wait, current); \
671 add_wait_queue(&wq, &__wait); \
672 for (;;) { \
673 current->state = TASK_UNINTERRUPTIBLE; \
674 if (condition) \
675 break; \
676 schedule(); \
678 current->state = TASK_RUNNING; \
679 remove_wait_queue(&wq, &__wait); \
680 } while (0)
682 #define wait_event(wq, condition) \
683 do { \
684 if (condition) \
685 break; \
686 __wait_event(wq, condition); \
687 } while (0)
689 #define __wait_event_interruptible(wq, condition, ret) \
690 do { \
691 wait_queue_t __wait; \
692 init_waitqueue_entry(&__wait, current); \
694 add_wait_queue(&wq, &__wait); \
695 for (;;) { \
696 current->state = TASK_INTERRUPTIBLE; \
697 if (condition) \
698 break; \
699 if (!signal_pending(current)) { \
700 schedule(); \
701 continue; \
703 ret = -ERESTARTSYS; \
704 break; \
706 current->state = TASK_RUNNING; \
707 remove_wait_queue(&wq, &__wait); \
708 } while (0)
710 #define wait_event_interruptible(wq, condition) \
711 ({ \
712 int __ret = 0; \
713 if (!(condition)) \
714 __wait_event_interruptible(wq, condition, __ret); \
715 __ret; \
718 #define REMOVE_LINKS(p) do { \
719 (p)->next_task->prev_task = (p)->prev_task; \
720 (p)->prev_task->next_task = (p)->next_task; \
721 if ((p)->p_osptr) \
722 (p)->p_osptr->p_ysptr = (p)->p_ysptr; \
723 if ((p)->p_ysptr) \
724 (p)->p_ysptr->p_osptr = (p)->p_osptr; \
725 else \
726 (p)->p_pptr->p_cptr = (p)->p_osptr; \
727 } while (0)
729 #define SET_LINKS(p) do { \
730 (p)->next_task = &init_task; \
731 (p)->prev_task = init_task.prev_task; \
732 init_task.prev_task->next_task = (p); \
733 init_task.prev_task = (p); \
734 (p)->p_ysptr = NULL; \
735 if (((p)->p_osptr = (p)->p_pptr->p_cptr) != NULL) \
736 (p)->p_osptr->p_ysptr = p; \
737 (p)->p_pptr->p_cptr = p; \
738 } while (0)
740 #define for_each_task(p) \
741 for (p = &init_task ; (p = p->next_task) != &init_task ; )
743 #endif /* __KERNEL__ */
745 #endif