1#ifndef _LINUX_SCHED_H
2#define _LINUX_SCHED_H
3
4#include <asm/param.h>
5
6extern unsigned long event;
7
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>
16
17#include <asm/system.h>
18#include <asm/semaphore.h>
19#include <asm/page.h>
20#include <asm/ptrace.h>
21#include <asm/mmu.h>
22
23#include <linux/smp.h>
24#include <linux/tty.h>
25#include <linux/sem.h>
26#include <linux/signal.h>
27#include <linux/securebits.h>
28#include <linux/fs_struct.h>
29
30
31
32
33#define CSIGNAL 0x000000ff
34#define CLONE_VM 0x00000100
35#define CLONE_FS 0x00000200
36#define CLONE_FILES 0x00000400
37#define CLONE_SIGHAND 0x00000800
38#define CLONE_PID 0x00001000
39#define CLONE_PTRACE 0x00002000
40#define CLONE_VFORK 0x00004000
41#define CLONE_PARENT 0x00008000
42#define CLONE_THREAD 0x00010000
43
44#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
45
46
47
48
49
50
51
52
53
54
55
56extern unsigned long avenrun[];
57
58#define FSHIFT 11
59#define FIXED_1 (1<<FSHIFT)
60#define LOAD_FREQ (5*HZ)
61#define EXP_1 1884
62#define EXP_5 2014
63#define EXP_15 2037
64
65#define CALC_LOAD(load,exp,n) \
66 load *= exp; \
67 load += n*(FIXED_1-exp); \
68 load >>= FSHIFT;
69
70#define CT_TO_SECS(x) ((x) / HZ)
71#define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ)
72
73extern int nr_running, nr_threads;
74extern int last_pid;
75
76#include <linux/fs.h>
77#include <linux/time.h>
78#include <linux/param.h>
79#include <linux/resource.h>
80#include <linux/timer.h>
81
82#include <asm/processor.h>
83
84#define TASK_RUNNING 0
85#define TASK_INTERRUPTIBLE 1
86#define TASK_UNINTERRUPTIBLE 2
87#define TASK_ZOMBIE 4
88#define TASK_STOPPED 8
89
90#define __set_task_state(tsk, state_value) \
91 do { (tsk)->state = (state_value); } while (0)
92#ifdef CONFIG_SMP
93#define set_task_state(tsk, state_value) \
94 set_mb((tsk)->state, (state_value))
95#else
96#define set_task_state(tsk, state_value) \
97 __set_task_state((tsk), (state_value))
98#endif
99
100#define __set_current_state(state_value) \
101 do { current->state = (state_value); } while (0)
102#ifdef CONFIG_SMP
103#define set_current_state(state_value) \
104 set_mb(current->state, (state_value))
105#else
106#define set_current_state(state_value) \
107 __set_current_state(state_value)
108#endif
109
110
111
112
113#define SCHED_OTHER 0
114#define SCHED_FIFO 1
115#define SCHED_RR 2
116
117
118
119
120
121#define SCHED_YIELD 0x10
122
123struct sched_param {
124 int sched_priority;
125};
126
127#ifdef __KERNEL__
128
129#include <linux/spinlock.h>
130
131
132
133
134
135
136
137extern rwlock_t tasklist_lock;
138extern spinlock_t runqueue_lock;
139extern spinlock_t mmlist_lock;
140
141extern void sched_init(void);
142extern void init_idle(void);
143extern void show_state(void);
144extern void cpu_init (void);
145extern void trap_init(void);
146extern void update_process_times(int user);
147extern void update_one_process(struct task_struct *p, unsigned long user,
148 unsigned long system, int cpu);
149
150#define MAX_SCHEDULE_TIMEOUT LONG_MAX
151extern signed long FASTCALL(schedule_timeout(signed long timeout));
152asmlinkage void schedule(void);
153
154extern int schedule_task(struct tq_struct *task);
155extern void flush_scheduled_tasks(void);
156extern int start_context_thread(void);
157extern int current_is_keventd(void);
158
159
160
161
162
163#define NR_OPEN_DEFAULT BITS_PER_LONG
164
165
166
167
168struct files_struct {
169 atomic_t count;
170 rwlock_t file_lock;
171 int max_fds;
172 int max_fdset;
173 int next_fd;
174 struct file ** fd;
175 fd_set *close_on_exec;
176 fd_set *open_fds;
177 fd_set close_on_exec_init;
178 fd_set open_fds_init;
179 struct file * fd_array[NR_OPEN_DEFAULT];
180};
181
182#define INIT_FILES \
183{ \
184 count: ATOMIC_INIT(1), \
185 file_lock: RW_LOCK_UNLOCKED, \
186 max_fds: NR_OPEN_DEFAULT, \
187 max_fdset: __FD_SETSIZE, \
188 next_fd: 0, \
189 fd: &init_files.fd_array[0], \
190 close_on_exec: &init_files.close_on_exec_init, \
191 open_fds: &init_files.open_fds_init, \
192 close_on_exec_init: { { 0, } }, \
193 open_fds_init: { { 0, } }, \
194 fd_array: { NULL, } \
195}
196
197
198#define MAX_MAP_COUNT (65536)
199
200
201#define AVL_MIN_MAP_COUNT 32
202
203struct mm_struct {
204 struct vm_area_struct * mmap;
205 struct vm_area_struct * mmap_avl;
206 struct vm_area_struct * mmap_cache;
207 pgd_t * pgd;
208 atomic_t mm_users;
209 atomic_t mm_count;
210 int map_count;
211 struct semaphore mmap_sem;
212 spinlock_t page_table_lock;
213
214 struct list_head mmlist;
215
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;
223 unsigned long swap_address;
224
225
226 mm_context_t context;
227};
228
229#define INIT_MM(name) \
230{ \
231 mmap: &init_mmap, \
232 mmap_avl: NULL, \
233 mmap_cache: NULL, \
234 pgd: swapper_pg_dir, \
235 mm_users: ATOMIC_INIT(2), \
236 mm_count: ATOMIC_INIT(1), \
237 map_count: 1, \
238 mmap_sem: __MUTEX_INITIALIZER(name.mmap_sem), \
239 page_table_lock: SPIN_LOCK_UNLOCKED, \
240 mmlist: LIST_HEAD_INIT(name.mmlist), \
241}
242
243struct signal_struct {
244 atomic_t count;
245 struct k_sigaction action[_NSIG];
246 spinlock_t siglock;
247};
248
249
250#define INIT_SIGNALS { \
251 count: ATOMIC_INIT(1), \
252 action: { {{0,}}, }, \
253 siglock: SPIN_LOCK_UNLOCKED \
254}
255
256
257
258
259struct user_struct {
260 atomic_t __count;
261 atomic_t processes;
262 atomic_t files;
263
264
265 struct user_struct *next, **pprev;
266 uid_t uid;
267};
268
269#define get_current_user() ({ \
270 struct user_struct *__user = current->user; \
271 atomic_inc(&__user->__count); \
272 __user; })
273
274extern struct user_struct root_user;
275#define INIT_USER (&root_user)
276
277struct task_struct {
278
279
280
281 volatile long state;
282 unsigned long flags;
283 int sigpending;
284 mm_segment_t addr_limit;
285
286
287
288 struct exec_domain *exec_domain;
289 volatile long need_resched;
290 unsigned long ptrace;
291
292 int lock_depth;
293
294
295
296
297
298
299 long counter;
300 long nice;
301 unsigned long policy;
302 struct mm_struct *mm;
303 int has_cpu, processor;
304 unsigned long cpus_allowed;
305
306
307
308
309 struct list_head run_list;
310 unsigned long sleep_time;
311
312 struct task_struct *next_task, *prev_task;
313 struct mm_struct *active_mm;
314
315
316 struct linux_binfmt *binfmt;
317 int exit_code, exit_signal;
318 int pdeath_signal;
319
320 unsigned long personality;
321 int dumpable:1;
322 int did_exec:1;
323 pid_t pid;
324 pid_t pgrp;
325 pid_t tty_old_pgrp;
326 pid_t session;
327 pid_t tgid;
328
329 int leader;
330
331
332
333
334
335 struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr;
336 struct list_head thread_group;
337
338
339 struct task_struct *pidhash_next;
340 struct task_struct **pidhash_pprev;
341
342 wait_queue_head_t wait_chldexit;
343 struct semaphore *vfork_sem;
344 unsigned long rt_priority;
345 unsigned long it_real_value, it_prof_value, it_virt_value;
346 unsigned long it_real_incr, it_prof_incr, it_virt_incr;
347 struct timer_list real_timer;
348 struct tms times;
349 unsigned long start_time;
350 long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS];
351
352 unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;
353 int swappable:1;
354
355 uid_t uid,euid,suid,fsuid;
356 gid_t gid,egid,sgid,fsgid;
357 int ngroups;
358 gid_t groups[NGROUPS];
359 kernel_cap_t cap_effective, cap_inheritable, cap_permitted;
360 int keep_capabilities:1;
361 struct user_struct *user;
362
363 struct rlimit rlim[RLIM_NLIMITS];
364 unsigned short used_math;
365 char comm[16];
366
367 int link_count;
368 struct tty_struct *tty;
369 unsigned int locks;
370
371 struct sem_undo *semundo;
372 struct sem_queue *semsleeping;
373
374 struct thread_struct thread;
375
376 struct fs_struct *fs;
377
378 struct files_struct *files;
379
380 spinlock_t sigmask_lock;
381 struct signal_struct *sig;
382
383 sigset_t blocked;
384 struct sigpending pending;
385
386 unsigned long sas_ss_sp;
387 size_t sas_ss_size;
388 int (*notifier)(void *priv);
389 void *notifier_data;
390 sigset_t *notifier_mask;
391
392
393 u32 parent_exec_id;
394 u32 self_exec_id;
395
396 spinlock_t alloc_lock;
397};
398
399
400
401
402#define PF_ALIGNWARN 0x00000001
403
404#define PF_STARTING 0x00000002
405#define PF_EXITING 0x00000004
406#define PF_FORKNOEXEC 0x00000040
407#define PF_SUPERPRIV 0x00000100
408#define PF_DUMPCORE 0x00000200
409#define PF_SIGNALED 0x00000400
410#define PF_MEMALLOC 0x00000800
411#define PF_VFORK 0x00001000
412
413#define PF_USEDFPU 0x00100000
414
415
416
417
418
419#define PT_PTRACED 0x00000001
420#define PT_TRACESYS 0x00000002
421#define PT_DTRACE 0x00000004
422#define PT_TRACESYSGOOD 0x00000008
423
424
425
426
427
428#define _STK_LIM (8*1024*1024)
429
430#define DEF_COUNTER (10*HZ/100)
431#define MAX_COUNTER (20*HZ/100)
432#define DEF_NICE (0)
433
434
435
436
437
438#define INIT_TASK(tsk) \
439{ \
440 state: 0, \
441 flags: 0, \
442 sigpending: 0, \
443 addr_limit: KERNEL_DS, \
444 exec_domain: &default_exec_domain, \
445 lock_depth: -1, \
446 counter: DEF_COUNTER, \
447 nice: DEF_NICE, \
448 policy: SCHED_OTHER, \
449 mm: NULL, \
450 active_mm: &init_mm, \
451 cpus_allowed: -1, \
452 run_list: LIST_HEAD_INIT(tsk.run_list), \
453 next_task: &tsk, \
454 prev_task: &tsk, \
455 p_opptr: &tsk, \
456 p_pptr: &tsk, \
457 thread_group: LIST_HEAD_INIT(tsk.thread_group), \
458 wait_chldexit: __WAIT_QUEUE_HEAD_INITIALIZER(tsk.wait_chldexit),\
459 real_timer: { \
460 function: it_real_fn \
461 }, \
462 cap_effective: CAP_INIT_EFF_SET, \
463 cap_inheritable: CAP_INIT_INH_SET, \
464 cap_permitted: CAP_FULL_SET, \
465 keep_capabilities: 0, \
466 rlim: INIT_RLIMITS, \
467 user: INIT_USER, \
468 comm: "swapper", \
469 thread: INIT_THREAD, \
470 fs: &init_fs, \
471 files: &init_files, \
472 sigmask_lock: SPIN_LOCK_UNLOCKED, \
473 sig: &init_signals, \
474 pending: { NULL, &tsk.pending.head, {{0}}}, \
475 blocked: {{0}}, \
476 alloc_lock: SPIN_LOCK_UNLOCKED \
477}
478
479
480#ifndef INIT_TASK_SIZE
481# define INIT_TASK_SIZE 2048*sizeof(long)
482#endif
483
484union task_union {
485 struct task_struct task;
486 unsigned long stack[INIT_TASK_SIZE/sizeof(long)];
487};
488
489extern union task_union init_task_union;
490
491extern struct mm_struct init_mm;
492extern struct task_struct *init_tasks[NR_CPUS];
493
494
495#define PIDHASH_SZ (4096 >> 2)
496extern struct task_struct *pidhash[PIDHASH_SZ];
497
498#define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
499
500static inline void hash_pid(struct task_struct *p)
501{
502 struct task_struct **htable = &pidhash[pid_hashfn(p->pid)];
503
504 if((p->pidhash_next = *htable) != NULL)
505 (*htable)->pidhash_pprev = &p->pidhash_next;
506 *htable = p;
507 p->pidhash_pprev = htable;
508}
509
510static inline void unhash_pid(struct task_struct *p)
511{
512 if(p->pidhash_next)
513 p->pidhash_next->pidhash_pprev = p->pidhash_pprev;
514 *p->pidhash_pprev = p->pidhash_next;
515}
516
517static inline struct task_struct *find_task_by_pid(int pid)
518{
519 struct task_struct *p, **htable = &pidhash[pid_hashfn(pid)];
520
521 for(p = *htable; p && p->pid != pid; p = p->pidhash_next)
522 ;
523
524 return p;
525}
526
527
528extern struct user_struct * alloc_uid(uid_t);
529extern void free_uid(struct user_struct *);
530
531#include <asm/current.h>
532
533extern unsigned long volatile jiffies;
534extern unsigned long itimer_ticks;
535extern unsigned long itimer_next;
536extern struct timeval xtime;
537extern void do_timer(struct pt_regs *);
538
539extern unsigned int * prof_buffer;
540extern unsigned long prof_len;
541extern unsigned long prof_shift;
542
543#define CURRENT_TIME (xtime.tv_sec)
544
545extern void FASTCALL(__wake_up(wait_queue_head_t *q, unsigned int mode, unsigned int wq_mode));
546extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, unsigned int wq_mode));
547extern void FASTCALL(sleep_on(wait_queue_head_t *q));
548extern long FASTCALL(sleep_on_timeout(wait_queue_head_t *q,
549 signed long timeout));
550extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q));
551extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q,
552 signed long timeout));
553extern void FASTCALL(wake_up_process(struct task_struct * tsk));
554
555#define wake_up(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE,WQ_FLAG_EXCLUSIVE)
556#define wake_up_all(x) __wake_up((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE,0)
557#define wake_up_sync(x) __wake_up_sync((x),TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE,WQ_FLAG_EXCLUSIVE)
558#define wake_up_interruptible(x) __wake_up((x),TASK_INTERRUPTIBLE,WQ_FLAG_EXCLUSIVE)
559#define wake_up_interruptible_all(x) __wake_up((x),TASK_INTERRUPTIBLE,0)
560#define wake_up_interruptible_sync(x) __wake_up_sync((x),TASK_INTERRUPTIBLE,WQ_FLAG_EXCLUSIVE)
561
562extern int in_group_p(gid_t);
563extern int in_egroup_p(gid_t);
564
565extern void proc_caches_init(void);
566extern void flush_signals(struct task_struct *);
567extern void flush_signal_handlers(struct task_struct *);
568extern int dequeue_signal(sigset_t *, siginfo_t *);
569extern void block_all_signals(int (*notifier)(void *priv), void *priv,
570 sigset_t *mask);
571extern void unblock_all_signals(void);
572extern int send_sig_info(int, struct siginfo *, struct task_struct *);
573extern int force_sig_info(int, struct siginfo *, struct task_struct *);
574extern int kill_pg_info(int, struct siginfo *, pid_t);
575extern int kill_sl_info(int, struct siginfo *, pid_t);
576extern int kill_proc_info(int, struct siginfo *, pid_t);
577extern void notify_parent(struct task_struct *, int);
578extern void do_notify_parent(struct task_struct *, int);
579extern void force_sig(int, struct task_struct *);
580extern int send_sig(int, struct task_struct *, int);
581extern int kill_pg(pid_t, int, int);
582extern int kill_sl(pid_t, int, int);
583extern int kill_proc(pid_t, int, int);
584extern int do_sigaction(int, const struct k_sigaction *, struct k_sigaction *);
585extern int do_sigaltstack(const stack_t *, stack_t *, unsigned long);
586
587static inline int signal_pending(struct task_struct *p)
588{
589 return (p->sigpending != 0);
590}
591
592
593
594
595
596static inline int has_pending_signals(sigset_t *signal, sigset_t *blocked)
597{
598 unsigned long ready;
599 long i;
600
601 switch (_NSIG_WORDS) {
602 default:
603 for (i = _NSIG_WORDS, ready = 0; --i >= 0 ;)
604 ready |= signal->sig[i] &~ blocked->sig[i];
605 break;
606
607 case 4: ready = signal->sig[3] &~ blocked->sig[3];
608 ready |= signal->sig[2] &~ blocked->sig[2];
609 ready |= signal->sig[1] &~ blocked->sig[1];
610 ready |= signal->sig[0] &~ blocked->sig[0];
611 break;
612
613 case 2: ready = signal->sig[1] &~ blocked->sig[1];
614 ready |= signal->sig[0] &~ blocked->sig[0];
615 break;
616
617 case 1: ready = signal->sig[0] &~ blocked->sig[0];
618 }
619 return ready != 0;
620}
621
622
623
624
625
626static inline void recalc_sigpending(struct task_struct *t)
627{
628 t->sigpending = has_pending_signals(&t->pending.signal, &t->blocked);
629}
630
631
632
633static inline int on_sig_stack(unsigned long sp)
634{
635 return (sp - current->sas_ss_sp < current->sas_ss_size);
636}
637
638static inline int sas_ss_flags(unsigned long sp)
639{
640 return (current->sas_ss_size == 0 ? SS_DISABLE
641 : on_sig_stack(sp) ? SS_ONSTACK : 0);
642}
643
644extern int request_irq(unsigned int,
645 void (*handler)(int, void *, struct pt_regs *),
646 unsigned long, const char *, void *);
647extern void free_irq(unsigned int, void *);
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663static inline int suser(void)
664{
665 if (!issecure(SECURE_NOROOT) && current->euid == 0) {
666 current->flags |= PF_SUPERPRIV;
667 return 1;
668 }
669 return 0;
670}
671
672static inline int fsuser(void)
673{
674 if (!issecure(SECURE_NOROOT) && current->fsuid == 0) {
675 current->flags |= PF_SUPERPRIV;
676 return 1;
677 }
678 return 0;
679}
680
681
682
683
684
685
686
687static inline int capable(int cap)
688{
689#if 1
690 if (cap_raised(current->cap_effective, cap))
691#else
692 if (cap_is_fs_cap(cap) ? current->fsuid == 0 : current->euid == 0)
693#endif
694 {
695 current->flags |= PF_SUPERPRIV;
696 return 1;
697 }
698 return 0;
699}
700
701
702
703
704extern struct mm_struct * mm_alloc(void);
705
706extern struct mm_struct * start_lazy_tlb(void);
707extern void end_lazy_tlb(struct mm_struct *mm);
708
709
710extern inline void FASTCALL(__mmdrop(struct mm_struct *));
711static inline void mmdrop(struct mm_struct * mm)
712{
713 if (atomic_dec_and_test(&mm->mm_count))
714 __mmdrop(mm);
715}
716
717
718extern void mmput(struct mm_struct *);
719
720extern void mm_release(void);
721
722
723
724
725extern struct file ** alloc_fd_array(int);
726extern int expand_fd_array(struct files_struct *, int nr);
727extern void free_fd_array(struct file **, int);
728
729extern fd_set *alloc_fdset(int);
730extern int expand_fdset(struct files_struct *, int nr);
731extern void free_fdset(fd_set *, int);
732
733extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *);
734extern void flush_thread(void);
735extern void exit_thread(void);
736
737extern void exit_mm(struct task_struct *);
738extern void exit_files(struct task_struct *);
739extern void exit_sighand(struct task_struct *);
740
741extern void daemonize(void);
742
743extern int do_execve(char *, char **, char **, struct pt_regs *);
744extern int do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long);
745
746extern void FASTCALL(add_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
747extern void FASTCALL(add_wait_queue_exclusive(wait_queue_head_t *q, wait_queue_t * wait));
748extern void FASTCALL(remove_wait_queue(wait_queue_head_t *q, wait_queue_t * wait));
749
750#define __wait_event(wq, condition) \
751do { \
752 wait_queue_t __wait; \
753 init_waitqueue_entry(&__wait, current); \
754 \
755 add_wait_queue(&wq, &__wait); \
756 for (;;) { \
757 set_current_state(TASK_UNINTERRUPTIBLE); \
758 if (condition) \
759 break; \
760 schedule(); \
761 } \
762 current->state = TASK_RUNNING; \
763 remove_wait_queue(&wq, &__wait); \
764} while (0)
765
766#define wait_event(wq, condition) \
767do { \
768 if (condition) \
769 break; \
770 __wait_event(wq, condition); \
771} while (0)
772
773#define __wait_event_interruptible(wq, condition, ret) \
774do { \
775 wait_queue_t __wait; \
776 init_waitqueue_entry(&__wait, current); \
777 \
778 add_wait_queue(&wq, &__wait); \
779 for (;;) { \
780 set_current_state(TASK_INTERRUPTIBLE); \
781 if (condition) \
782 break; \
783 if (!signal_pending(current)) { \
784 schedule(); \
785 continue; \
786 } \
787 ret = -ERESTARTSYS; \
788 break; \
789 } \
790 current->state = TASK_RUNNING; \
791 remove_wait_queue(&wq, &__wait); \
792} while (0)
793
794#define wait_event_interruptible(wq, condition) \
795({ \
796 int __ret = 0; \
797 if (!(condition)) \
798 __wait_event_interruptible(wq, condition, __ret); \
799 __ret; \
800})
801
802#define REMOVE_LINKS(p) do { \
803 (p)->next_task->prev_task = (p)->prev_task; \
804 (p)->prev_task->next_task = (p)->next_task; \
805 if ((p)->p_osptr) \
806 (p)->p_osptr->p_ysptr = (p)->p_ysptr; \
807 if ((p)->p_ysptr) \
808 (p)->p_ysptr->p_osptr = (p)->p_osptr; \
809 else \
810 (p)->p_pptr->p_cptr = (p)->p_osptr; \
811 } while (0)
812
813#define SET_LINKS(p) do { \
814 (p)->next_task = &init_task; \
815 (p)->prev_task = init_task.prev_task; \
816 init_task.prev_task->next_task = (p); \
817 init_task.prev_task = (p); \
818 (p)->p_ysptr = NULL; \
819 if (((p)->p_osptr = (p)->p_pptr->p_cptr) != NULL) \
820 (p)->p_osptr->p_ysptr = p; \
821 (p)->p_pptr->p_cptr = p; \
822 } while (0)
823
824#define for_each_task(p) \
825 for (p = &init_task ; (p = p->next_task) != &init_task ; )
826
827#define next_thread(p) \
828 list_entry((p)->thread_group.next, struct task_struct, thread_group)
829
830static inline void del_from_runqueue(struct task_struct * p)
831{
832 nr_running--;
833 p->sleep_time = jiffies;
834 list_del(&p->run_list);
835 p->run_list.next = NULL;
836}
837
838static inline int task_on_runqueue(struct task_struct *p)
839{
840 return (p->run_list.next != NULL);
841}
842
843static inline void unhash_process(struct task_struct *p)
844{
845 if (task_on_runqueue(p)) BUG();
846 write_lock_irq(&tasklist_lock);
847 nr_threads--;
848 unhash_pid(p);
849 REMOVE_LINKS(p);
850 list_del(&p->thread_group);
851 write_unlock_irq(&tasklist_lock);
852}
853
854static inline void task_lock(struct task_struct *p)
855{
856 spin_lock(&p->alloc_lock);
857}
858
859static inline void task_unlock(struct task_struct *p)
860{
861 spin_unlock(&p->alloc_lock);
862}
863
864
865static inline char * d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
866 char *buf, int buflen)
867{
868 char *res;
869 struct vfsmount *rootmnt;
870 struct dentry *root;
871 read_lock(¤t->fs->lock);
872 rootmnt = mntget(current->fs->rootmnt);
873 root = dget(current->fs->root);
874 read_unlock(¤t->fs->lock);
875 spin_lock(&dcache_lock);
876 res = __d_path(dentry, vfsmnt, root, rootmnt, buf, buflen);
877 spin_unlock(&dcache_lock);
878 dput(root);
879 mntput(rootmnt);
880 return res;
881}
882
883#endif
884
885#endif
886