linux下的sched头文件.docx
- 文档编号:18413676
- 上传时间:2023-08-16
- 格式:DOCX
- 页数:31
- 大小:124.36KB
linux下的sched头文件.docx
《linux下的sched头文件.docx》由会员分享,可在线阅读,更多相关《linux下的sched头文件.docx(31页珍藏版)》请在冰点文库上搜索。
linux下的sched头文件
/*
*include/linux/schedh
*
*/
#ifndef_LINUX_SCHED_H
#define_LINUX_SCHED_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
structexec_domain;
/*
*cloningflags:
*/
#defineCSIGNAL
0x000000ff/*signalmasktobesentatexit*/
#defineCLONE_VM0x00000100
#defineCLONE_FS0x00000200
#defineCLONE_FILES0x00000400
/*setifVMsharedbetweenprocesses*/
/*setiffsinfosharedbetweenprocesses*/
/*setifopenfilessharedbetweenprocesses*/
#defineCLONE_SIGHAND0x00000800/*setifsignalhandlersandblockedsignals
shared*/
#defineCLONE_PID0x00001000/*setifpidshared*/
#defineCLONE_PTRACE0x00002000/*setifwewanttolettracingcontinuechildtoo*/
#defineCLONE_VFORK0x00004000/*setiftheparentwantsthechildtowakeituponmm_release*/
onthe
#defineCLONE_PARENT0x00008000/*setifwewanttohavethesameparent
asthe
cloner*/
#defineCLONE_THREAD0x00010000/*Samethreadgroup?
*/#defineCLONE_NEWNS0x00020000/*Newnamespacegroup?
*/#defineCLONE_SIGNAL(CLONE_SIGHAND|CLONE_THREAD)
/**Thesearetheconstantusedtofakethefixed-pointload-average
*counting.Somenotes:
*-11bitfractionsexpandto22bitsbythemultiplies:
thisgives
*aload-averageprecisionof10bitsinteger+11bitsfractional
*-ifyouwanttocountload-averagesmoreoften,youneedmore
*precision,orroundingwillgetyou.With2-secondcountingfreq,
*theEXP_nvalueswouldbe1981,2034and2043ifstillusingonly
*11bitfractions.
*/
load+=n*(FIXED_1-exp);\load>>=FSHIFT;
#defineCT_TO_SECS(x)((x)/HZ)
#defineCT_TO_USECS(x)(((x)%HZ)*1000000/HZ)externintnr_threads;
externintlast_pid;
externunsignedlongnr_running(void);externunsignedlongnr_uninterruptible(void);
#include
#include
#include
#include
//进程状态
#defineTASK_RUNNING0
#defineTASK_INTERRUPTIBLE1
#defineTASK_UNINTERRUPTIBLE2
#defineTASK_ZOMBIE4
#defineTASK_STOPPED8#define__set_task_state(tsk,state_value)
do{(tsk)->state=(state_value);}while(0)#ifdefCONFIG_SMP
#defineset_task_state(tsk,state_value)
set_mb((tsk)->state,(state_value))
#else
#defineset_task_state(tsk,state_value)
set_task_state((tsk),(state_value))
#endif
#define__set_current_state(state_value)
do{current->state=(state_value);}while(0)#ifdefCONFIG_SMP
#defineset_current_state(state_value)
set_mb(current->state,(state_value))
#else
#defineset_current_state(state_value)
__set_current_state(state_value)
#endif
/*
*Schedulingpolicies
*/
#defineSCHED_OTHER0
#defineSCHED_FIFO1
#defineSCHED_RR2
structsched_param{
intsched_priority;
};
structcompletion;
#ifdef__KERNEL__
#include
/*
*Thisserializes"schedule()"andalsoprotects
*therun-queuefromdeletions/modifications(but
*_adding_tothebeginningoftherun-queuehas
*aseparatelock).
*/
externrwlock_ttasklist_lock;
externspinlock_tmmlist_lock;
typedefstructtask_structtask_t;//将task_t定义为task_sturct的结构类型externvoidsched_init(void);
externvoidinit_idle(task_t*idle,intcpu);
externvoidshow_state(void);
externvoidshow_stack(unsignedlong*esp);
externvoidcpu_init(void);
externvoidtrap_init(void);
externvoidupdate_process_times(intuser);
externvoidupdate_one_process(task_t*p,unsignedlonguser,
unsignedlongsystem,intcpu);
externvoidscheduler_tick(intuser_tick,intsystem);
externvoidmigration_init(void);
externunsignedlongcache_decay_ticks;
externintset_user(uid_tnew_ruid,intdumpclear);
#defineMAX_SCHEDULE_TIMEOUTLONG_MAX
externsignedlongFASTCALL(schedule_timeout(signedlongtimeout));asmlinkagevoidschedule(void);
externintschedule_task(structtq_struct*task);
externvoidflush_scheduled_tasks(void);
externintstart_context_thread(void);
externintcurrent_is_keventd(void);
/*优先级
*Priorityofaprocessgoesfrom0..MAX_PRIO-1,validRT
*priorityis0..MAX_RT_PRIO-1,andSCHED_OTHERtasksare
*intherangeMAX_RT_PRIO..MAX_PRIO-1.Priorityvalues
*areinverted:
lowerp->priovaluemeanshigherpriority.
*
*TheMAX_RT_USER_PRIOvalueallowstheactualmaximum
*RTprioritytobeseparatefromthevalueexportedto
*user-space.Thisallowskernelthreadstosettheir
*prioritytoavaluehigherthananyusertask.Note:
*MAX_RT_PRIOmustnotbesmallerthanMAX_USER_RT_PRIO.
*/
#defineMAX_USER_RT_PRIO100
#defineMAX_RT_PRIOMAX_USER_RT_PRIO
#defineMAX_PRIO(MAX_RT_PRIO+40)
/*
*ThemaximumRTpriorityisconfigurable.Iftheresulting
*bitmapis160-bits,wecanuseahand-codedroutinewhich
*isoptimal.Otherwise,wefallbackonagenericroutinefor
*findingthefirstsetbitfromanarbitrarily-sizedbitmap.
*/
#ifMAX_PRIO<160&&MAX_PRIO>127
#definesched_find_first_bit(map)_sched_find_first_bit(map)
#else
#definesched_find_first_bit(map)find_first_bit(map,MAX_PRIO)
#endif
/*
*ThedefaultfdarrayneedstobeatleastBITS_PER_LONG,
*asthisisthegranularityreturnedbycopy_fdset().
*/
#defineNR_OPEN_DEFAULTBITS_PER_LONGstructnamespace;
/*文件系统数据结构
*Openfiletablestructure
*/structfiles_struct{atomic_tcount;rwlock_tfile_lock;/*Protectsallthebelowmembers.Nests
tsk->alloc_lock*/
intmax_fds;intmax_fdset;
intnext_fd;
structfile**fd;/*currentfdarray*/fd_set*close_on_exec;
fd_set*open_fds;
fd_setclose_on_exec_init;
fd_setopen_fds_init;structfile*fd_array[NR_OPEN_DEFAULT];
};
#defineINIT_FILES\
{\count:
ATOMIC_INIT
(1),\
file_lock:
RW_LOCK_UNLOCKED,\
max_fds:
NR_OPEN_DEFAULT,\
max_fdset:
__FD_SETSIZE,\
next_fd:
0,\fd:
&init_files.fd_array[0],\
close_on_exec:
&init_files.close_on_exec_init,\open_fds:
&init_files.open_fds_init,\close_on_exec_init:
{{0,}},\
open_fds_init:
{{0,}},\
fd_array:
{NULL,}\
}
/*Maximumnumberofactivemapareas..Thisisarandom(large)number*/#defineDEFAULT_MAX_MAP_COUNT(65536)externintmax_map_count;
//存储管理数据结构structmm_struct{
structvm_area_struct*mmap;/*listofVMAs*/rb_root_tmm_rb;
structvm_area_struct*mmap_cache;/*lastfind_vmaresult*/pgd_t*pgd;
atomic_tmm_users;/*Howmanyuserswithuserspace?
*/
inside
(users
atomic_tmm_count;/*Howmanyreferencesto"structmm_struct"
countas1)*/intmap_count;/*numberofVMAs*/
structrw_semaphoremmap_sem;
spinlock_tpage_table_lock;/*Protectstaskpagetablesandmm->rss*/
structlist_headmmlist;/*Listofallactivemm's.Theseareglobally
strung
*togetheroffinit_mm.mmlist,andareprotected
*bymmlist_lock*/
unsignedlongstart_code,end_code,start_data,end_data;unsignedlongstart_brk,brk,start_stack;
unsignedlongarg_start,arg_end,env_start,env_end;
unsignedlongrss,total_vm,locked_vm;
unsignedlongdef_flags;
unsignedlongcpu_vm_mask;
unsignedlongrlimit_rss;
unsigneddumpable:
1;
/*Architecture-specificMMcontext*/mm_context_tcontext;
};//结束存储管理数据结构定义
externintmmlist_nr;
#defineINIT_MM(name)\
{\
mm_rb:
RB_ROOT,\pgd:
swapper_pg_dir,\
mm_users:
ATOMIC_INIT
(2),\
mm_count:
ATOMIC_INIT
(1),\
mmap_sem:
__RWSEM_INITIALIZER(name.mmap_sem),\
page_table_lock:
SPIN_LOCK_UNLOCKED,\
mmlist:
LIST_HEAD_INIT(name.mmlist),\
rlimit_rss:
RLIM_INFINITY,\}
//信号数据结构
};
#defineINIT_SIGNALS{\
count:
ATOMIC_INIT
(1),\
action:
{{{0,}},},\
siglock:
SPIN_LOCK_UNLOCKED\
}
/*user结构定义
*Somedaythiswillbeafull-fledgedusertrackingsystem..
*/structuser_struct{
atomic_t__count;/*referencecount*/
atomic_tprocesses;/*Howmanyprocessesdoesthisuserhave?
*/atomic_tfiles;/*Howmanyopenfilesdoesthisuserhave?
*/
/*Hashtablemaintenanceinformation*/structuser_struct*next,**pprev;
uid_tuid;
};
#defineget_current_user()({\
structuser_struct*__user=current->user;\
atomic_inc(&__user->__count);\
__user;})
externstructuser_structroot_user;
#defineINIT_USER(&root_user)typedefstructprio_arrayprio_array_t;
//进程控制块
structtask_struct{
/*
*offsetsofthesearehardcodedelsewhere-touchwithcare
*/
volatilelongstate;/*-1unrunnable,0runnable,>0stopped*/
unsignedlongflags;/*perprocessflags,definedbelow*/intsigpending;
//虚拟地址空间上限
mm_segment_taddr_limit;/*threadaddressspace:
0-0xBFFFFFFFforuser-thead0-0xFFFFFFFFforkernel-thread
*/
//指向本进程所述执行域的数据结构。
//(由应用程序在不同版本之间的差异所造成不同的执行域)
structexec_domain*exec_domain;
//CPU从系统空间返回到用户空间之前要进行一次调度
volatilelongneed_resched;unsignedlongptrace;
intlock_depth;/*Lockdepth*//*
*offset32beginshereon32-bitplatforms.*/
//就绪进程队列
unsignedintcpu;intprio,static_prio;list_trun_list;prio_array_t*array;
unsignedlongsleep_avg;
unsignedlongsleep_timestamp;
unsignedlongpolicy;//调度策略
unsignedlongcpus_allowed;
unsignedinttime_slice,first_time_slice;//时间片
//以init_task为首的所有进程,按创建次序先后插入链中,为遍历提供方便
task_t*next_task,*prev_task;
structmm_struct*mm,*active_mm;//所用的内存资源
/*taskstate*/
structlinux_binfmt*binfmt;//应用程序文件格式,如a.out
intexit_code,exit_signal;//在exit()和wait4()中用到
intpdeath_signal;/*Thesignalsentwhentheparentdies*/
/*
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- linux sched 文件
![提示](https://static.bingdoc.com/images/bang_tan.gif)