4 #include <asm/param.h> /* for HZ */
6 extern unsigned long event
;
8 #include <linux/config.h>
9 #include <linux/binfmts.h>
10 #include <linux/personality.h>
11 #include <linux/threads.h>
12 #include <linux/kernel.h>
13 #include <linux/types.h>
14 #include <linux/times.h>
15 #include <linux/timex.h>
17 #include <asm/system.h>
18 #include <asm/semaphore.h>
20 #include <asm/ptrace.h>
22 #include <linux/smp.h>
23 #include <linux/tty.h>
24 #include <linux/sem.h>
25 #include <linux/signal.h>
26 #include <linux/securebits.h>
27 #include <linux/fs_struct.h>
32 #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */
33 #define CLONE_VM 0x00000100 /* set if VM shared between processes */
34 #define CLONE_FS 0x00000200 /* set if fs info shared between processes */
35 #define CLONE_FILES 0x00000400 /* set if open files shared between processes */
36 #define CLONE_SIGNAL 0x00000800 /* set if signal handlers and blocked signals shared */
37 #define CLONE_PID 0x00001000 /* set if pid shared */
38 #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
39 #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
40 #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
42 #define CLONE_SIGHAND CLONE_SIGNAL /* Old name */
45 * These are the constant used to fake the fixed-point load-average
46 * counting. Some notes:
47 * - 11 bit fractions expand to 22 bits by the multiplies: this gives
48 * a load-average precision of 10 bits integer + 11 bits fractional
49 * - if you want to count load-averages more often, you need more
50 * precision, or rounding will get you. With 2-second counting freq,
51 * the EXP_n values would be 1981, 2034 and 2043 if still using only
54 extern unsigned long avenrun
[]; /* Load averages */
56 #define FSHIFT 11 /* nr of bits of precision */
57 #define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
58 #define LOAD_FREQ (5*HZ) /* 5 sec intervals */
59 #define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */
60 #define EXP_5 2014 /* 1/exp(5sec/5min) */
61 #define EXP_15 2037 /* 1/exp(5sec/15min) */
63 #define CALC_LOAD(load,exp,n) \
65 load += n*(FIXED_1-exp); \
68 #define CT_TO_SECS(x) ((x) / HZ)
69 #define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ)
71 extern int nr_running
, nr_threads
;
75 #include <linux/time.h>
76 #include <linux/param.h>
77 #include <linux/resource.h>
78 #include <linux/timer.h>
80 #include <asm/processor.h>
82 #define TASK_RUNNING 0
83 #define TASK_INTERRUPTIBLE 1
84 #define TASK_UNINTERRUPTIBLE 2
86 #define TASK_STOPPED 8
87 #define TASK_EXCLUSIVE 32
89 #define __set_task_state(tsk, state_value) \
90 do { (tsk)->state = (state_value); } while (0)
92 #define set_task_state(tsk, state_value) \
93 set_mb((tsk)->state, (state_value))
95 #define set_task_state(tsk, state_value) \
96 __set_task_state((tsk), (state_value))
99 #define __set_current_state(state_value) \
100 do { current->state = (state_value); } while (0)
102 #define set_current_state(state_value) \
103 set_mb(current->state, (state_value))
105 #define set_current_state(state_value) \
106 __set_current_state(state_value)
110 * Scheduling policies
112 #define SCHED_OTHER 0
117 * This is an additional bit set when we want to
118 * yield the CPU for one re-schedule..
120 #define SCHED_YIELD 0x10
128 #include <linux/spinlock.h>
131 * This serializes "schedule()" and also protects
132 * the run-queue from deletions/modifications (but
133 * _adding_ to the beginning of the run-queue has
136 extern rwlock_t tasklist_lock
;
137 extern spinlock_t runqueue_lock
;
139 extern void sched_init(void);
140 extern void init_idle(void);
141 extern void show_state(void);
142 extern void cpu_init (void);
143 extern void trap_init(void);
144 extern void update_process_times(int user
);
145 extern void update_one_process(struct task_struct
*p
, unsigned long user
,
146 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, \
189 /* Maximum number of active map areas.. This is a random (large) number */
190 #define MAX_MAP_COUNT (65536)
192 /* Number of map areas at which the AVL tree is activated. This is arbitrary. */
193 #define AVL_MIN_MAP_COUNT 32
196 struct vm_area_struct
* mmap
; /* list of VMAs */
197 struct vm_area_struct
* mmap_avl
; /* tree of VMAs */
198 struct vm_area_struct
* mmap_cache
; /* last find_vma result */
200 atomic_t mm_users
; /* How many users with user space? */
201 atomic_t mm_count
; /* How many references to "struct mm_struct" (users count as 1) */
202 int map_count
; /* number of VMAs */
203 struct semaphore mmap_sem
;
204 spinlock_t page_table_lock
;
205 unsigned long context
;
206 unsigned long start_code
, end_code
, start_data
, end_data
;
207 unsigned long start_brk
, brk
, start_stack
;
208 unsigned long arg_start
, arg_end
, env_start
, env_end
;
209 unsigned long rss
, total_vm
, locked_vm
;
210 unsigned long def_flags
;
211 unsigned long cpu_vm_mask
;
212 unsigned long swap_cnt
; /* number of pages to swap on next pass */
213 unsigned long swap_address
;
215 * This is an architecture-specific pointer: the portable
216 * part of Linux does not know about any segments.
221 #define INIT_MM(name) { \
222 &init_mmap, NULL, NULL, \
224 ATOMIC_INIT(2), ATOMIC_INIT(1), 1, \
225 __MUTEX_INITIALIZER(name.mmap_sem), \
226 SPIN_LOCK_UNLOCKED, \
234 struct signal_struct
{
236 struct k_sigaction action
[_NSIG
];
241 #define INIT_SIGNALS { \
247 * Some day this will be a full-fledged user tracking system..
250 atomic_t __count
; /* reference count */
251 atomic_t processes
; /* How many processes does this user have? */
252 atomic_t files
; /* How many open files does this user have? */
254 /* Hash table maintenance information */
255 struct user_struct
*next
, **pprev
;
259 #define get_current_user() ({ \
260 struct user_struct *__user = current->user; \
261 atomic_inc(&__user->__count); \
264 extern struct user_struct root_user
;
265 #define INIT_USER (&root_user)
269 * offsets of these are hardcoded elsewhere - touch with care
271 volatile long state
; /* -1 unrunnable, 0 runnable, >0 stopped */
272 unsigned long flags
; /* per process flags, defined below */
274 mm_segment_t addr_limit
; /* thread address space:
275 0-0xBFFFFFFF for user-thead
276 0-0xFFFFFFFF for kernel-thread
278 struct exec_domain
*exec_domain
;
279 volatile long need_resched
;
280 unsigned long ptrace
;
282 int lock_depth
; /* Lock depth */
285 * offset 32 begins here on 32-bit platforms. We keep
286 * all fields in a single cacheline that are needed for
287 * the goodness() loop in schedule().
291 unsigned long policy
;
292 struct mm_struct
*mm
;
293 int has_cpu
, processor
;
294 unsigned long cpus_allowed
;
296 * (only the 'next' pointer fits into the cacheline, but
299 struct list_head run_list
;
301 struct task_struct
*next_task
, *prev_task
;
302 struct mm_struct
*active_mm
;
305 struct linux_binfmt
*binfmt
;
306 int exit_code
, exit_signal
;
307 int pdeath_signal
; /* The signal sent when the parent dies */
309 unsigned long personality
;
317 /* boolean value for session group leader */
320 * pointers to (original) parent process, youngest child, younger sibling,
321 * older sibling, respectively. (p->father can be replaced with
324 struct task_struct
*p_opptr
, *p_pptr
, *p_cptr
, *p_ysptr
, *p_osptr
;
325 struct list_head thread_group
;
327 /* PID hash table linkage. */
328 struct task_struct
*pidhash_next
;
329 struct task_struct
**pidhash_pprev
;
331 wait_queue_head_t wait_chldexit
; /* for wait4() */
332 struct semaphore
*vfork_sem
; /* for vfork() */
333 unsigned long rt_priority
;
334 unsigned long it_real_value
, it_prof_value
, it_virt_value
;
335 unsigned long it_real_incr
, it_prof_incr
, it_virt_incr
;
336 struct timer_list real_timer
;
338 unsigned long start_time
;
339 long per_cpu_utime
[NR_CPUS
], per_cpu_stime
[NR_CPUS
];
340 /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
341 unsigned long min_flt
, maj_flt
, nswap
, cmin_flt
, cmaj_flt
, cnswap
;
343 /* process credentials */
344 uid_t uid
,euid
,suid
,fsuid
;
345 gid_t gid
,egid
,sgid
,fsgid
;
347 gid_t groups
[NGROUPS
];
348 kernel_cap_t cap_effective
, cap_inheritable
, cap_permitted
;
349 int keep_capabilities
:1;
350 struct user_struct
*user
;
352 struct rlimit rlim
[RLIM_NLIMITS
];
353 unsigned short used_math
;
355 /* file system info */
357 struct tty_struct
*tty
; /* NULL if no tty */
359 struct sem_undo
*semundo
;
360 struct sem_queue
*semsleeping
;
361 /* CPU-specific state of this task */
362 struct thread_struct thread
;
363 /* filesystem information */
364 struct fs_struct
*fs
;
365 /* open file information */
366 struct files_struct
*files
;
367 /* signal handlers */
368 spinlock_t sigmask_lock
; /* Protects signal and blocked */
369 struct signal_struct
*sig
;
372 struct sigpending pending
;
374 unsigned long sas_ss_sp
;
376 int (*notifier
)(void *priv
);
378 sigset_t
*notifier_mask
;
380 /* Thread group tracking */
383 /* Protection of (de-)allocation: mm, files, fs, tty */
384 spinlock_t alloc_lock
;
390 #define PF_ALIGNWARN 0x00000001 /* Print alignment warning msgs */
391 /* Not implemented yet, only for 486*/
392 #define PF_STARTING 0x00000002 /* being created */
393 #define PF_EXITING 0x00000004 /* getting shut down */
394 #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */
395 #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */
396 #define PF_DUMPCORE 0x00000200 /* dumped core */
397 #define PF_SIGNALED 0x00000400 /* killed by a signal */
398 #define PF_MEMALLOC 0x00000800 /* Allocating memory */
399 #define PF_VFORK 0x00001000 /* Wake up parent in mm_release */
401 #define PF_USEDFPU 0x00100000 /* task used FPU this quantum (SMP) */
407 #define PT_PTRACED 0x00000001
408 #define PT_TRACESYS 0x00000002
409 #define PT_DTRACE 0x00000004 /* delayed trace (used on m68k, i386) */
412 * Limit the stack by to some sane default: root can always
413 * increase this limit if needed.. 8MB seems reasonable.
415 #define _STK_LIM (8*1024*1024)
417 #define DEF_COUNTER (10*HZ/100) /* 100 ms time slice */
418 #define MAX_COUNTER (20*HZ/100)
422 * INIT_TASK is used to set up the first task table, touch at
423 * your own risk!. Base=0, limit=0x1fffff (=2MB)
425 #define INIT_TASK(tsk) \
430 addr_limit: KERNEL_DS, \
431 exec_domain: &default_exec_domain, \
433 counter: DEF_COUNTER, \
435 policy: SCHED_OTHER, \
437 active_mm: &init_mm, \
439 run_list: LIST_HEAD_INIT(tsk.run_list), \
444 thread_group: LIST_HEAD_INIT(tsk.thread_group), \
445 wait_chldexit: __WAIT_QUEUE_HEAD_INITIALIZER(tsk.wait_chldexit),\
447 function: it_real_fn \
449 cap_effective: CAP_INIT_EFF_SET, \
450 cap_inheritable: CAP_INIT_INH_SET, \
451 cap_permitted: CAP_FULL_SET, \
452 keep_capabilities: 0, \
453 rlim: INIT_RLIMITS, \
456 thread: INIT_THREAD, \
458 files: &init_files, \
459 sigmask_lock: SPIN_LOCK_UNLOCKED, \
460 sig: &init_signals, \
461 pending: { NULL, &tsk.pending.head, {{0}}}, \
463 alloc_lock: SPIN_LOCK_UNLOCKED \
467 #ifndef INIT_TASK_SIZE
468 # define INIT_TASK_SIZE 2048*sizeof(long)
472 struct task_struct task
;
473 unsigned long stack
[INIT_TASK_SIZE
/sizeof(long)];
476 extern union task_union init_task_union
;
478 extern struct mm_struct init_mm
;
479 extern struct task_struct
*init_tasks
[NR_CPUS
];
481 /* PID hashing. (shouldnt this be dynamic?) */
482 #define PIDHASH_SZ (4096 >> 2)
483 extern struct task_struct
*pidhash
[PIDHASH_SZ
];
485 #define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
487 static inline void hash_pid(struct task_struct
*p
)
489 struct task_struct
**htable
= &pidhash
[pid_hashfn(p
->pid
)];
491 if((p
->pidhash_next
= *htable
) != NULL
)
492 (*htable
)->pidhash_pprev
= &p
->pidhash_next
;
494 p
->pidhash_pprev
= htable
;
497 static inline void unhash_pid(struct task_struct
*p
)
500 p
->pidhash_next
->pidhash_pprev
= p
->pidhash_pprev
;
501 *p
->pidhash_pprev
= p
->pidhash_next
;
504 static inline struct task_struct
*find_task_by_pid(int pid
)
506 struct task_struct
*p
, **htable
= &pidhash
[pid_hashfn(pid
)];
508 for(p
= *htable
; p
&& p
->pid
!= pid
; p
= p
->pidhash_next
)
514 /* per-UID process charging. */
515 extern struct user_struct
* alloc_uid(uid_t
);
516 extern void free_uid(struct user_struct
*);
518 #include <asm/current.h>
520 extern unsigned long volatile jiffies
;
521 extern unsigned long itimer_ticks
;
522 extern unsigned long itimer_next
;
523 extern struct timeval xtime
;
524 extern void do_timer(struct pt_regs
*);
526 extern unsigned int * prof_buffer
;
527 extern unsigned long prof_len
;
528 extern unsigned long prof_shift
;
530 #define CURRENT_TIME (xtime.tv_sec)
532 extern void FASTCALL(__wake_up(wait_queue_head_t
*q
, unsigned int mode
));
533 extern void FASTCALL(__wake_up_sync(wait_queue_head_t
*q
, unsigned int mode
));
534 extern void FASTCALL(sleep_on(wait_queue_head_t
*q
));
535 extern long FASTCALL(sleep_on_timeout(wait_queue_head_t
*q
,
536 signed long timeout
));
537 extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t
*q
));
538 extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t
*q
,
539 signed long timeout
));
540 extern void FASTCALL(wake_up_process(struct task_struct
* tsk
));
542 #define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE | TASK_EXCLUSIVE)
543 #define wake_up_all(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE)
544 #define wake_up_sync(x) __wake_up_sync((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE | TASK_EXCLUSIVE)
545 #define wake_up_interruptible(x) __wake_up((x),TASK_INTERRUPTIBLE | TASK_EXCLUSIVE)
546 #define wake_up_interruptible_all(x) __wake_up((x),TASK_INTERRUPTIBLE)
547 #define wake_up_interruptible_sync(x) __wake_up_sync((x),TASK_INTERRUPTIBLE | TASK_EXCLUSIVE)
549 extern int in_group_p(gid_t
);
550 extern int in_egroup_p(gid_t
);
552 extern void proc_caches_init(void);
553 extern void flush_signals(struct task_struct
*);
554 extern void flush_signal_handlers(struct task_struct
*);
555 extern int dequeue_signal(sigset_t
*, siginfo_t
*);
556 extern void block_all_signals(int (*notifier
)(void *priv
), void *priv
,
558 extern void unblock_all_signals(void);
559 extern int send_sig_info(int, struct siginfo
*, struct task_struct
*);
560 extern int force_sig_info(int, struct siginfo
*, struct task_struct
*);
561 extern int kill_pg_info(int, struct siginfo
*, pid_t
);
562 extern int kill_sl_info(int, struct siginfo
*, pid_t
);
563 extern int kill_proc_info(int, struct siginfo
*, pid_t
);
564 extern void notify_parent(struct task_struct
*, int);
565 extern void do_notify_parent(struct task_struct
*, int);
566 extern void force_sig(int, struct task_struct
*);
567 extern int send_sig(int, struct task_struct
*, int);
568 extern int kill_pg(pid_t
, int, int);
569 extern int kill_sl(pid_t
, int, int);
570 extern int kill_proc(pid_t
, int, int);
571 extern int do_sigaction(int, const struct k_sigaction
*, struct k_sigaction
*);
572 extern int do_sigaltstack(const stack_t
*, stack_t
*, unsigned long);
574 static inline int signal_pending(struct task_struct
*p
)
576 return (p
->sigpending
!= 0);
580 * Re-calculate pending state from the set of locally pending
581 * signals, globally pending signals, and blocked signals.
583 static inline int has_pending_signals(sigset_t
*signal
, sigset_t
*blocked
)
588 switch (_NSIG_WORDS
) {
590 for (i
= _NSIG_WORDS
, ready
= 0; --i
>= 0 ;)
591 ready
|= signal
->sig
[i
] &~ blocked
->sig
[i
];
594 case 4: ready
= signal
->sig
[3] &~ blocked
->sig
[3];
595 ready
|= signal
->sig
[2] &~ blocked
->sig
[2];
596 ready
|= signal
->sig
[1] &~ blocked
->sig
[1];
597 ready
|= signal
->sig
[0] &~ blocked
->sig
[0];
600 case 2: ready
= signal
->sig
[1] &~ blocked
->sig
[1];
601 ready
|= signal
->sig
[0] &~ blocked
->sig
[0];
604 case 1: ready
= signal
->sig
[0] &~ blocked
->sig
[0];
609 /* Reevaluate whether the task has signals pending delivery.
610 This is required every time the blocked sigset_t changes.
611 All callers should have t->sigmask_lock. */
613 static inline void recalc_sigpending(struct task_struct
*t
)
615 t
->sigpending
= has_pending_signals(&t
->pending
.signal
, &t
->blocked
);
618 /* True if we are on the alternate signal stack. */
620 static inline int on_sig_stack(unsigned long sp
)
622 return (sp
- current
->sas_ss_sp
< current
->sas_ss_size
);
625 static inline int sas_ss_flags(unsigned long sp
)
627 return (current
->sas_ss_size
== 0 ? SS_DISABLE
628 : on_sig_stack(sp
) ? SS_ONSTACK
: 0);
631 extern int request_irq(unsigned int,
632 void (*handler
)(int, void *, struct pt_regs
*),
633 unsigned long, const char *, void *);
634 extern void free_irq(unsigned int, void *);
637 * This has now become a routine instead of a macro, it sets a flag if
638 * it returns true (to do BSD-style accounting where the process is flagged
639 * if it uses root privs). The implication of this is that you should do
640 * normal permissions checks first, and check suser() last.
642 * [Dec 1997 -- Chris Evans]
643 * For correctness, the above considerations need to be extended to
644 * fsuser(). This is done, along with moving fsuser() checks to be
647 * These will be removed, but in the mean time, when the SECURE_NOROOT
648 * flag is set, uids don't grant privilege.
650 static inline int suser(void)
652 if (!issecure(SECURE_NOROOT
) && current
->euid
== 0) {
653 current
->flags
|= PF_SUPERPRIV
;
659 static inline int fsuser(void)
661 if (!issecure(SECURE_NOROOT
) && current
->fsuid
== 0) {
662 current
->flags
|= PF_SUPERPRIV
;
669 * capable() checks for a particular capability.
670 * New privilege checks should use this interface, rather than suser() or
671 * fsuser(). See include/linux/capability.h for defined capabilities.
674 static inline int capable(int cap
)
677 if (cap_raised(current
->cap_effective
, cap
))
679 if (cap_is_fs_cap(cap
) ? current
->fsuid
== 0 : current
->euid
== 0)
682 current
->flags
|= PF_SUPERPRIV
;
689 * Routines for handling mm_structs
691 extern struct mm_struct
* mm_alloc(void);
693 extern struct mm_struct
* start_lazy_tlb(void);
694 extern void end_lazy_tlb(struct mm_struct
*mm
);
696 /* mmdrop drops the mm and the page tables */
697 extern inline void FASTCALL(__mmdrop(struct mm_struct
*));
698 static inline void mmdrop(struct mm_struct
* mm
)
700 if (atomic_dec_and_test(&mm
->mm_count
))
704 /* mmput gets rid of the mappings and all user-space */
705 extern void mmput(struct mm_struct
*);
706 /* Remove the current tasks stale references to the old mm_struct */
707 extern void mm_release(void);
710 * Routines for handling the fd arrays
712 extern struct file
** alloc_fd_array(int);
713 extern int expand_fd_array(struct files_struct
*, int nr
);
714 extern void free_fd_array(struct file
**, int);
716 extern fd_set
*alloc_fdset(int);
717 extern int expand_fdset(struct files_struct
*, int nr
);
718 extern void free_fdset(fd_set
*, int);
720 extern int copy_thread(int, unsigned long, unsigned long, struct task_struct
*, struct pt_regs
*);
721 extern void flush_thread(void);
722 extern void exit_thread(void);
724 extern void exit_mm(struct task_struct
*);
725 extern void exit_files(struct task_struct
*);
726 extern void exit_sighand(struct task_struct
*);
728 extern void daemonize(void);
730 extern int do_execve(char *, char **, char **, struct pt_regs
*);
731 extern int do_fork(unsigned long, unsigned long, struct pt_regs
*);
733 extern void FASTCALL(add_wait_queue(wait_queue_head_t
*q
, wait_queue_t
* wait
));
734 extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t
*q
, wait_queue_t
* wait
));
735 extern void FASTCALL(remove_wait_queue(wait_queue_head_t
*q
, wait_queue_t
* wait
));
737 #define __wait_event(wq, condition) \
739 wait_queue_t __wait; \
740 init_waitqueue_entry(&__wait, current); \
742 add_wait_queue(&wq, &__wait); \
744 set_current_state(TASK_UNINTERRUPTIBLE); \
749 current->state = TASK_RUNNING; \
750 remove_wait_queue(&wq, &__wait); \
753 #define wait_event(wq, condition) \
757 __wait_event(wq, condition); \
760 #define __wait_event_interruptible(wq, condition, ret) \
762 wait_queue_t __wait; \
763 init_waitqueue_entry(&__wait, current); \
765 add_wait_queue(&wq, &__wait); \
767 set_current_state(TASK_INTERRUPTIBLE); \
770 if (!signal_pending(current)) { \
774 ret = -ERESTARTSYS; \
777 current->state = TASK_RUNNING; \
778 remove_wait_queue(&wq, &__wait); \
781 #define wait_event_interruptible(wq, condition) \
785 __wait_event_interruptible(wq, condition, __ret); \
789 #define REMOVE_LINKS(p) do { \
790 (p)->next_task->prev_task = (p)->prev_task; \
791 (p)->prev_task->next_task = (p)->next_task; \
793 (p)->p_osptr->p_ysptr = (p)->p_ysptr; \
795 (p)->p_ysptr->p_osptr = (p)->p_osptr; \
797 (p)->p_pptr->p_cptr = (p)->p_osptr; \
800 #define SET_LINKS(p) do { \
801 (p)->next_task = &init_task; \
802 (p)->prev_task = init_task.prev_task; \
803 init_task.prev_task->next_task = (p); \
804 init_task.prev_task = (p); \
805 (p)->p_ysptr = NULL; \
806 if (((p)->p_osptr = (p)->p_pptr->p_cptr) != NULL) \
807 (p)->p_osptr->p_ysptr = p; \
808 (p)->p_pptr->p_cptr = p; \
811 #define for_each_task(p) \
812 for (p = &init_task ; (p = p->next_task) != &init_task ; )
814 #define next_thread(p) \
815 list_entry((p)->thread_group.next, struct task_struct, thread_group)
817 static inline void del_from_runqueue(struct task_struct
* p
)
820 list_del(&p
->run_list
);
821 p
->run_list
.next
= NULL
;
824 static inline int task_on_runqueue(struct task_struct
*p
)
826 return (p
->run_list
.next
!= NULL
);
829 static inline void unhash_process(struct task_struct
*p
)
831 if (task_on_runqueue(p
)) BUG();
832 write_lock_irq(&tasklist_lock
);
836 list_del(&p
->thread_group
);
837 write_unlock_irq(&tasklist_lock
);
840 static inline void task_lock(struct task_struct
*p
)
842 spin_lock(&p
->alloc_lock
);
845 static inline void task_unlock(struct task_struct
*p
)
847 spin_unlock(&p
->alloc_lock
);
850 /* write full pathname into buffer and return start of pathname */
851 static inline char * d_path(struct dentry
*dentry
, struct vfsmount
*vfsmnt
,
852 char *buf
, int buflen
)
855 struct vfsmount
*rootmnt
;
857 read_lock(¤t
->fs
->lock
);
858 rootmnt
= mntget(current
->fs
->rootmnt
);
859 root
= dget(current
->fs
->root
);
860 read_unlock(¤t
->fs
->lock
);
861 spin_lock(&dcache_lock
);
862 res
= __d_path(dentry
, vfsmnt
, root
, rootmnt
, buf
, buflen
);
863 spin_unlock(&dcache_lock
);
869 #endif /* __KERNEL__ */