| 1 | #ifndef _LINUX_SCHED_H |
|---|
| 2 | #define _LINUX_SCHED_H |
|---|
| 3 | |
|---|
| 4 | #include <asm/param.h> /* for HZ */ |
|---|
| 5 | |
|---|
| 6 | #include <linux/capability.h> |
|---|
| 7 | #include <linux/threads.h> |
|---|
| 8 | #include <linux/kernel.h> |
|---|
| 9 | #include <linux/types.h> |
|---|
| 10 | #include <linux/rbtree.h> |
|---|
| 11 | |
|---|
| 12 | #include <asm/page.h> |
|---|
| 13 | #include <asm/ptrace.h> |
|---|
| 14 | |
|---|
| 15 | #include <linux/sem.h> |
|---|
| 16 | #include <linux/signal.h> |
|---|
| 17 | #include <linux/securebits.h> |
|---|
| 18 | #include <linux/fs.h> |
|---|
| 19 | |
|---|
| 20 | struct exec_domain; |
|---|
| 21 | |
|---|
| 22 | /* |
|---|
| 23 | * cloning flags: |
|---|
| 24 | */ |
|---|
| 25 | #define CSIGNAL 0x000000ff /* signal mask to be sent at exit */ |
|---|
| 26 | #define CLONE_VM 0x00000100 /* set if VM shared between processes */ |
|---|
| 27 | #define CLONE_FS 0x00000200 /* set if fs info shared between processes */ |
|---|
| 28 | #define CLONE_FILES 0x00000400 /* set if open files shared between processes */ |
|---|
| 29 | #define CLONE_SIGHAND 0x00000800 /* set if signal handlers and blocked signals shared */ |
|---|
| 30 | #define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */ |
|---|
| 31 | #define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ |
|---|
| 32 | #define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ |
|---|
| 33 | #define CLONE_THREAD 0x00010000 /* Same thread group? */ |
|---|
| 34 | #define CLONE_NEWNS 0x00020000 /* New namespace group? */ |
|---|
| 35 | #define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */ |
|---|
| 36 | #define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */ |
|---|
| 37 | #define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */ |
|---|
| 38 | #define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */ |
|---|
| 39 | #define CLONE_DETACHED 0x00400000 /* Unused, ignored */ |
|---|
| 40 | #define CLONE_UNTRACED 0x00800000 /* set if the tracing process can't force CLONE_PTRACE on this clone */ |
|---|
| 41 | #define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */ |
|---|
| 42 | #define CLONE_STOPPED 0x02000000 /* Start in stopped state */ |
|---|
| 43 | |
|---|
| 44 | /* |
|---|
| 45 | * List of flags we want to share for kernel threads, |
|---|
| 46 | * if only because they are not used by them anyway. |
|---|
| 47 | */ |
|---|
| 48 | #define CLONE_KERNEL (CLONE_FS | CLONE_FILES | CLONE_SIGHAND) |
|---|
| 49 | |
|---|
| 50 | /* |
|---|
| 51 | * These are the constant used to fake the fixed-point load-average |
|---|
| 52 | * counting. Some notes: |
|---|
| 53 | * - 11 bit fractions expand to 22 bits by the multiplies: this gives |
|---|
| 54 | * a load-average precision of 10 bits integer + 11 bits fractional |
|---|
| 55 | * - if you want to count load-averages more often, you need more |
|---|
| 56 | * precision, or rounding will get you. With 2-second counting freq, |
|---|
| 57 | * the EXP_n values would be 1981, 2034 and 2043 if still using only |
|---|
| 58 | * 11 bit fractions. |
|---|
| 59 | */ |
|---|
| 60 | extern unsigned long avenrun[]; /* Load averages */ |
|---|
| 61 | |
|---|
| 62 | #define FSHIFT 11 /* nr of bits of precision */ |
|---|
| 63 | #define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */ |
|---|
| 64 | #define LOAD_FREQ (5*HZ) /* 5 sec intervals */ |
|---|
| 65 | #define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */ |
|---|
| 66 | #define EXP_5 2014 /* 1/exp(5sec/5min) */ |
|---|
| 67 | #define EXP_15 2037 /* 1/exp(5sec/15min) */ |
|---|
| 68 | |
|---|
| 69 | #define CALC_LOAD(load,exp,n) \ |
|---|
| 70 | load *= exp; \ |
|---|
| 71 | load += n*(FIXED_1-exp); \ |
|---|
| 72 | load >>= FSHIFT; |
|---|
| 73 | |
|---|
| 74 | #define CT_TO_SECS(x) ((x) / HZ) |
|---|
| 75 | #define CT_TO_USECS(x) (((x) % HZ) * 1000000/HZ) |
|---|
| 76 | |
|---|
| 77 | #include <sys/time.h> |
|---|
| 78 | #include <linux/param.h> |
|---|
| 79 | #include <linux/resource.h> |
|---|
| 80 | |
|---|
| 81 | #define TASK_RUNNING 0 |
|---|
| 82 | #define TASK_INTERRUPTIBLE 1 |
|---|
| 83 | #define TASK_UNINTERRUPTIBLE 2 |
|---|
| 84 | #define TASK_STOPPED 4 |
|---|
| 85 | #define TASK_TRACED 8 |
|---|
| 86 | #define EXIT_ZOMBIE 16 |
|---|
| 87 | #define EXIT_DEAD 32 |
|---|
| 88 | |
|---|
| 89 | #define __set_task_state(tsk, state_value) \ |
|---|
| 90 | do { (tsk)->state = (state_value); } while (0) |
|---|
| 91 | #define set_task_state(tsk, state_value) \ |
|---|
| 92 | set_mb((tsk)->state, (state_value)) |
|---|
| 93 | |
|---|
| 94 | #define __set_current_state(state_value) \ |
|---|
| 95 | do { current->state = (state_value); } while (0) |
|---|
| 96 | #define set_current_state(state_value) \ |
|---|
| 97 | set_mb(current->state, (state_value)) |
|---|
| 98 | |
|---|
| 99 | /* Task command name length */ |
|---|
| 100 | #define TASK_COMM_LEN 16 |
|---|
| 101 | |
|---|
| 102 | /* |
|---|
| 103 | * Scheduling policies |
|---|
| 104 | */ |
|---|
| 105 | #define SCHED_NORMAL 0 |
|---|
| 106 | #define SCHED_FIFO 1 |
|---|
| 107 | #define SCHED_RR 2 |
|---|
| 108 | |
|---|
| 109 | struct sched_param { |
|---|
| 110 | int sched_priority; |
|---|
| 111 | }; |
|---|
| 112 | |
|---|
| 113 | #endif |
|---|