收藏 分销(赏)

linux下的sched头文件.docx

上传人:二*** 文档编号:4575311 上传时间:2024-09-30 格式:DOCX 页数:28 大小:64.51KB
下载 相关 举报
linux下的sched头文件.docx_第1页
第1页 / 共28页
亲,该文档总共28页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、* include/linux/schedh*/ttifndef _LINUX_SCHED_Httdefine _LINUX_SCHED_H #include /* for HZ */ extern unsigned long event;#include ttinclude ttinclude 4include 4include #include ttinclude #include#include ttinclude ttinclude 4include 4include #include ttinclude #include 4include ttinclude #include #in

2、clude ttinclude ttinclude ttinclude ttinclude #include 4include include ttinclude struct execdomain;* cloning flags:ttdefine CSIGNAL4define CLONE_VM#define CLONE_FSOxOOOOOOff0x000001000x00000200ttdefine CLONE FILES 0x00000400/* signal mask to be sent at exit */* set if VM shared between processes */

3、* set if fs info shared between processes */* set if open files shared between processes */*进程家谱pointers to (original) parent process, youngest child, younger sibling,* older sibling, respectively. (p-father can be replaced withp-p_pptr-pid). 父选程 -i I-p.ppirP、pirP-PPtrP-PPtrP_Op【rJ :rosptr 队年轻的干进种,户

4、一样工7 老的子薪P,pirP-ys/rtaskt *p_opptr, *p_pptr, *p_cptr, *p_ysptr, *p_osptr;struct listhead threadgroup;以进程号位索引查找hash表,定位进程控制块task_sturct/* PID hash table linkage. */taskt *pidhashnext;task_t *pidhash_pprev;wait_queue_head_t wait_chldexit;/* for wait4() */struct completion *vfork done;/* for vfork() */

5、unsigned long rt_priority;unsigned long it_real_value, it_prof_value, it_virt_value;unsigned long it_real_incr, it_prof_incr, it_virt_incr;struct timer_list real_timer;struct tms times;#if HZ=100unsigned long start_time;#elseu64 start_time; Sendif该进程在各处理机上运行的累计时间(用户空间上utime,和系统空间上stime) long per_cpu

6、_utimeNR_CPUS, per_cpu_stimeNR_CPUS;对页面异常次数的统计maj_flt和换入/换出次数的统计nswap/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */unsigned longmaj_fIt, nswap, cmin_flt, cmaj_flt, cnswap;int swappable:1;/* process credentials凭证,与文件操作权限有关*/uid_t uid,euid, suid, fsuid

7、;gid_t gid,egid, sgid, fsgid;int ngroups;gid t groupsNGROUPS;kernel_cap_t capeffective, capinheritable, cap_permitted;int keep_capabilities: 1 ;授权进程的各种操作的权限,比特权用户方式更细了 struct user_struct *user;在 fork。中使用limits所用资源在量上的限制*/struct rlimit rlimRLIM_NLIMITS;unsigned short usedmath;char comm16;file system

8、info 文件资源 */ int link_count, total_link_count;struct ttystruct *tty; /* NULL if no tty */unsigned int locks; /* How many file locks are being held */ ipc stuff */struct sem_undo *semundo;struct sem queue *semsleeping;CPU-specific state of this task */struct thread_struct thread;线程结构定义filesystem info

9、rmation文件管理表格指针*/ struct fsstruct *fs;open file information */ struct files_struct *files;namespace */struct namespace *namespace;signal handlers */spinlock_t sigmask_lock; /* Protects signal and blocked */ struct signal_struct *sig; /指向 signal_struct 数据结构sigset_t blocked;struct sigpending pending;u

10、nsigned long sas_ss_sp;size_t sas_ss_size;int (*notifier) (void *priv);void *notifierdata; sigsett *notifier_mask;/* TUX state */ void *tuxinfo; void (*tux_exit)(void);unsigned long cpus_allowed_mask;Thread group tracking 在 exit ()和 wait4()中用到*/u32 parent_exec_id;u32 self_exec_id;/* Protection of (d

11、e-)allocation: mm, files, fs, tty */ spinlockt alloc lock;/* journalling filesystem info */ void *journal_info;; 进程控制块结束task_struct* Per process flags#define PF_ALIGNWARN0x00000001 /* Print alignment warning msgs */* Not implemented yet, only for 486*/being created */getting shut down */* forked but

12、 didn,t exec */being created */getting shut down */* forked but didn,t exec */4define PF_STARTING 0x00000002 /*4define PF_EXITING 0x00000004 /* ttdefine PF FORKNOEXEC 0x00000040define PF_SUPERPRIV0x00000100 /* used super-user privileges */#define PF DUMPCORE 0x00000200 #define PF_SIGNALED 0x00000400

13、4define PF_MEMALLOC 0x00000800define PF_MEMDIE 0x00001000/* dumped core */* killed by a signal */* Allocating memory */* Killed for out-of-memory */define PF_FREE_PAGESdefine PF_NOIO#define PF_FROZEN ttdefine PF_FREEZE0x000040000x000080000x00010000define PF_IOTHREAD 0x00020000/* avoid generating fur

14、ther 1/0 */* frozen for system suspend */* this task should be frozen for suspend */* this thread is needed for doing I/O to swap */#define PF_KERNTHREADbe sent signals to */0x00040000 /* this thread is a kernel thread that cannot4define PFJJSEDFPU0x00100000 /* task used FPU this quantum (SMP) */* P

15、trace flags4define PT_PTRACED 0x00000001#define PT_TRACESYS 0x00000002define PT DTRACE 0x00000004/* delayed trace (used on m68k,i386) */ttdefine PT_TRACESYSGOOD 0x00000008ttdefine PT_PTRACE_CAP0x00000010 /* ptracer can follow suid-exec */* Limit the stack by to some sane default: root can always0x00

16、002000 /* per process page freeing */* increase this limit if needed. . 8MB seems reasonable.*/#define _STK_LIM (8*1024*1024)ttifdef CONFIG SMPextern void set_cpus_allowed(task_t *p, unsigned long new_mask);#else#define set_cpus_allowed(p, new_mask) do while (0)#endif extern void setusernice(taskt *

17、p, long nice);extern int task_prio(task_t *p);extern int task_nice(task_t *p);extern int idle_cpu(int cpu);asmlinkage long sys_sched_yield(void);#define yieldO sys_sched_yield() /* The default (Linux) execution domain.*/extern struct exec_domain default_exec_domain;* INITTASK is used to set up the f

18、irst task table, touch at * your own risk!. Base=0, limit=Oxlfffff (=2MB)ttdefine INIT_TASK(tsk) (state:0,flags:0,sigpending:sigpending:0,addr_limit:addr_limit:KERNEL DS,exec domain:exec domain:&default exec domain,lockdepth:-1,prio:MAX_PRI0-20,static_prio:MAX_PRI0-20,policy:SCHED_OTHER,cpusallowed:

19、-1,cpus_allowedmask: -1,mm:NULL,active_mm:&init_mm,run_list:LIST_HEAD_INIT(tsk. run_list),time_slice:HZ,nexttask: &tsk, prev_task: &tsk, p_opptr: &tsk, p_pptr: &tsk,thread group: wait_chldexit:real_timer: function: ),capeffective:LIST HEAD INIT(tsk. thread group),_WAIT_QUEUE_HEAD_INITIALIZER(tsk. wa

20、it_chldexit), it real fnCAP_INIT_EFF_SET,cap_inheritable:CAP_INIT_INH_SET,cap_permitted: CAPFULLSET, keep_capabilities: 0,rlim:user:comm: thread: fs: files:INIT RLIMITS, INIT_USER, swapper”, INIT_THREAD, &init_fs, &init_files,sigmask_lock: SPIN_L0CK_UNL0CKED,sig: pending: blocked: alloc lock:sig: pe

21、nding: blocked: alloc lock:&init_signals,journal_info: NULL, &tsk. pending, head, 0, 0,SPIN_LOCKUNLOCKED,NULL,ttifndef INIT TASK SIZE# define INIT_TASK_SIZE 2048*sizeof(long) ttendifunion taskunion task t task;unsigned long stackINIT_TASK_SIZE/sizeof(long); );extern union task_union init_task_union;

22、extern struct mm_struct initmm;extern task_t *init_tasksNR_CPUS;/* PID hashing, (shouldnt this be dynamic?) */ttdefine PIDHASH_SZ (4096 2)extern taskt *pidhashPIDHASH_SZ;ttdefine pid_hashfn(x) (x) 8)八(x) & (PIDHASH_SZ - 1)static inline void hash pid(taskt *p) (task_t *htable = &pidhashpid_hashfn(p-p

23、id);if (p-pidhash_next = *htable) != NULL)(*htable)-pidhash_pprev = &p-pidhash_next;*htable = p;p-pidhash_pprev = htable;static inline void unhash_pid(task_t *p) (if(p-pidhash_next) p-pidhash_next-pidhash_pprev = p-pidhash_pprev;*p-pidhash pprev = p-pidhash next;)static inline task_t *find_task_by_p

24、id(int pid) (task t *p, *htable = &pidhashpid hashfn(pid);for(p = *htable; p & p-pid != pid; p = p-pidhash_next)*return p;/* per-UID process charging. */extern struct user_struct * alloc_uid(uid_t);extern void free uid(struct user struct *);#include /* The 64-bit value is not volatile - you MUST NOT

25、 read it* without holding read_lock_irq(&xtime_lock)*/ extern u64 jiffies_64;extern unsigned long volatile jiffies;extern unsigned long itimer_ticks;extern unsigned long itimer_next;extern struct timeval xtime;extern void do_timer(struct pt_regs *);extern unsigned int * prof buffer;extern unsigned l

26、ong prof_len;extern unsigned long prof_shift;#define CURRENTSIME (xtime. tv_sec) extern void FASTCALL(_wake_up(wait_queue_head_t *q, unsigned int mode, int nr); extern void FASTCALL(_wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr);extern void FASTCALL(sleep on(wait_queue head t *q);ext

27、ern long FASTCALL(s1eep on timeout(wait_queue_head_t *q, signed long timeout);extern void FASTCALL(interruptible_sleep_on(wait_queue_head_t *q);extern long FASTCALL(interruptible_sleep_on_timeout(wait_queue_head_t *q, signed long timeout);extern int FASTCALL(wakeup process(taskt * tsk);extern void F

28、ASTCALL(wake_up_forked_process(task_t * tsk);extern void FASTCALL(sched_exit(task_t * p);#define wake-up(x)_wake_up(x), TASK_UNINTERRUPTIBLE|TASK_INTERRUPTIBLE, 1)#define wake_up_nr(x, nr)_wake_up(x), TASK_UNINTERRUPTIBLE|TASK_INTERRUPTIBLE, nr)ttdefine wake_up_all(x)_wake_up (x), TASK_UNINTERRUPTIB

29、LE|TASK INTERRUPTIBLE, 0)#define wake_up_interruptible(x)_wake_up(x), TASK INTERRUPTIBLE, 1)#define wake_up_interruptible_nr (x, nr) _wake_up (x), TASK INTERRUPTIBLE, nr)#define wake_up_interruptible_all(x)_wake_up(x), TASK_INTERRUPTIBLE, 0)#ifdef CONFIG_SMPttdefinewake up interruptible sync(x) wake

30、 up sync(x), TASK INTERRUPTIBLE, 1)#else#define wake_up_interruptible_sync (x)_wake_up(x), TASK INTERRUPTIBLE, 1)ttendif asmlinkage long sys wait4(pid t pid,unsigned int * stat addr, int options, struct rusage * ru);extern int in_group_p(gid_t);extern int in_egroup_p(gid_t);extern extern extern exte

31、rn extern externextern extern extern extern extern externvoid void void voidproc_caches_init(void);flush_signals(task_t *);flush_signal_handlers(task_t *);sig exit (int, int, struct siginfo *);extern extern extern extern extern extern extern extern extern extern extern extern extern extern externint

32、 dequeue signal(sigset_t *, siginfot *);void block_all_signals(int (*notifier) (void *priv), void *priv, sigset_t *mask);void unblock_all_signals(void);int int int int intsend_sig_info(int, struct siginfo *, task_t *); force_sig_info(int, struct siginfo *, taskt *); kill_pg_info(int, struct siginfo

33、*, pidt); kill_sl_info(int, struct siginfo *, pid_t);kill_proc_info(int, struct siginfo *, pid_t);void notify_parent(taskt *, int); void do_notify_parent(task_t *, int);void force_sig(int, task_t *);int int int int int intsend_sig(int, task_t *, int);kill_pg(pid_t, int, int);kill sl (pid t, int, int

34、);kill proc(pid t, int, int);do_sigaction(int, const struct k_sigaction do_sigaltstack(const stack_t *, stack_t *,*, struct k_sigaction *); unsigned long);staticstaticinline int signal pending (task t *p)return (p-sigpending != 0);/* Re-calculate pending state from the set of locally pending* signal

35、s, globally pending signals, and blocked signals.*/static inline int has_pending_signals(sigset_t *signal, sigset_t *blocked) (unsigned long ready;long i;switch (_NSIG_WORDS) default:for (i = _NSIG_WORDS, ready = 0; -i = 0 ;)ready |= signal-sigi &blocked-sigi;break;case 4: ready = signal-sig3 & bloc

36、ked-sig3; ready |= signal-sig2 &blocked-sig2; ready |二 signal-sigl blocked-sigl;ready |= signal-sigO &blocked-sig0; break;case 2: ready = signal-sigl &blocked-sigl;ready |= signal-sigO blocked-sig0;break;case 1: ready = signal-sigO &blocked-sigO;return ready != 0;/* Reevaluate whether the task has s

37、ignals pending delivery.This is required every time the blocked sigset_t changes.All callers should have t-sigmask_lock. */static inline void recalc_sigpending(taskt *t) t-sigpending = has_pending_signals(&t-pending. signal, &t-blocked); )/* True if we are on the alternate signal stack. */static inl

38、ine int on_sig_stack(unsigned long sp) (return (sp - current-sas_ss_sp sas_ss_size);)static inline int sas_ss_flags(unsigned long sp) (return (current-sas_ss_size = 0 ? SS DISABLE :on sig stack(sp) ? SS ONSTACK : 0);)extern int request_irq(unsigned int,void (*handler)(int, void *, struct pt_regs *),

39、 unsigned long, const char *, void *);extern void free_irq(unsigned int, void *);/* This has now become a routine instead of a macro, it sets a flag if* it returns true (to do BSD-style accounting where the process is flagged* if it uses root privs). The implication of this is that you should do* no

40、rmal permissions checks first, and check suser() last.* Dec 1997 - Chris Evans* For correctness, the above considerations need to be extended to* fsuser(). This is done, along with moving fsuser() checks to be* last.* These will be removed, but in the mean time, when the SECURE_NOROOT* flag is set,

41、uids don,t grant privilege.*/static inline int suser(void)if (!issecure(SECURENOROOT) & current-euid = 0) current-flags |= PFSUPERPRIV;return 1;return 0;)static inline int fsuser(void)(if (!issecure(SECURE_NOROOT) & current-fsuid =二 0) current-flags |= PFSUPERPRIV;return 1;)return 0;* capable() chec

42、ks for a particular capability.* New privilege checks should use this interface, rather than suser() or* fsuser (). See include/linux/capability. h for defined capabilities.static inline int capable(int cap)(#if 1 /* ok now */if (cap raised(current-cap effective, cap)#elseif (cap_is_fs_cap(cap) ? cu

43、rrent-fsuid = 0 : current-euid = 0) ttendifcurrent-flags |= PFSUPERPRIV;#define CLONESIGHAND0x00000800 /* set if signal handlers and blocked signalsshared */#define CL0NE_PID 0x00001000 /* set if pid shared */#define CLONE PTRACE 0x00002000 /* set if we want to let tracing continue on the child too

44、*/#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */#def ine CLONE_PARENT0x00008000 /* set if we want to have the same parent as thecloner */#define CLONETHREAD0x00010000 /* Same thread group? */#define CLONENEWNS 0x00020000 /* New namespace group? */d

45、efine CLONE_SIGNAL (CLONE_SIGIIAND | CLONE_TIIREAD)/* These are the constant used to fake the fixed-point load-average* counting. Some notes:* - 11 bit fractions expand to 22 bits by the multiplies: this gives* a load-average precision of 10 bits integer + 11 bits fractional* 一 if you want to count load-averages more often, you need more* precision, or rounding wi11 get you. With 2-second counting freq,* the EXP_n values would be 1981, 2034 and 2043 if still using only* 11 bit fractions.*/extern unsigned long avenrun;/* Load a

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 通信科技 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服