資源簡介
minix內核修改,增加實時進程和實時調度:
1 增加系統調用chrt
? 函數格式
s = chrt(long deadline)
? 函數功能
設置進程為實時進程并在deadline秒后結束。如果deadline為0,則將進程設置為非實時進程。設置成功返回0,否則返回1.
2 實現EDF(Earliest-Deadline-First)實時調度算法
? EDF
deadline越近的進程越先執行
? 實時調度
設置進程的優先級,保證進程的優先級高于其他用戶進程,以保證它的實時性。但要考慮不會影響系統進程的執行。

代碼片段和文件信息
/*?This?file?contains?the?main?program?of?MINIX?as?well?as?its?shutdown?code.
?*?The?routine?main()?initializes?the?system?and?starts?the?ball?rolling?by
?*?setting?up?the?process?table?interrupt?vectors?and?scheduling?each?task?
?*?to?run?to?initialize?itself.
?*?The?routine?shutdown()?does?the?opposite?and?brings?down?MINIX.?
?*
?*?The?entries?into?this?file?are:
?*???main: ???? MINIX?main?program
?*???prepare_shutdown: prepare?to?take?MINIX?down
?*/
#include?“kernel.h“
#include?
#include?
#include?
#include?
#include?
#include?“proc.h“
#include?“debug.h“
#include?“clock.h“
/*?Prototype?declarations?for?PRIVATE?functions.?*/
FORWARD?_PROTOTYPE(?void?announce?(void));
/*===========================================================================*
?* main?????????????????????????????????????????*
?*===========================================================================*/
PUBLIC?void?main()
{
/*?Start?the?ball?rolling.?*/
??struct?boot_image?*ip; /*?boot?image?pointer?*/
??register?struct?proc?*rp; /*?process?pointer?*/
??register?struct?priv?*sp; /*?privilege?structure?pointer?*/
??register?int?i?j;
??int?hdrindex; /*?index?to?array?of?a.out?headers?*/
??phys_clicks?text_base;
??vir_clicks?text_clicks?data_clicks?st_clicks;
??reg_t?ktsb; /*?kernel?task?stack?base?*/
??struct?exec?e_hdr; /*?for?a?copy?of?an?a.out?header?*/
???/*?Global?value?to?test?segment?sanity.?*/
???magictest?=?MAGICTEST;
?
??/*?Clear?the?process?table.?Anounce?each?slot?as?empty?and?set?up?mappings?
???*?for?proc_addr()?and?proc_nr()?macros.?Do?the?same?for?the?table?with?
???*?privilege?structures?for?the?system?processes.?
???*/
??for?(rp?=?BEG_PROC_ADDR?i?=?-NR_TASKS;?rp??? rp->p_rts_flags?=?RTS_SLOT_FREE; /*?initialize?free?slot?*/
rp->p_deadline.tmr_exp_time?=?0;?/*?realtime?scheduling*/
#if?DEBUG_SCHED_CHECK
rp->p_magic?=?PMAGIC;
#endif
rp->p_nr?=?i; /*?proc?number?from?ptr?*/
rp->p_endpoint?=?_ENDPOINT(0?rp->p_nr);?/*?generation?no.?0?*/
??}
??for?(sp?=?BEG_PRIV_ADDR?i?=?0;?sp? sp->s_proc_nr?=?NONE; /*?initialize?as?free?*/
sp->s_id?=?(proc_nr_t)?i; /*?priv?structure?index?*/
ppriv_addr[i]?=?sp; /*?priv?ptr?from?number?*/
??}
??/*?Set?up?proc?table?entries?for?processes?in?boot?image.??The?stacks?of?the
???*?kernel?tasks?are?initialized?to?an?array?in?data?space.??The?stacks
???*?of?the?servers?have?been?added?to?the?data?segment?by?the?monitor?so
???*?the?stack?pointer?is?set?to?the?end?of?the?data?segment.??All?the
???*?processes?are?in?low?memory?on?the?8086.??On?the?386?only?the?kernel
???*?is?in?low?memory?the?rest?is?loaded?in?extended?memory.
???*/
??/*?Task?stacks.?*/
??ktsb?=?(reg_t)?t_stack;
??for?(i=0;?i? int?schedulable_proc;
proc_nr_t?proc_nr;
int?ipc_to_m?kcalls;
ip?=?&image[i]; /*?proc
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????78848??2010-05-22?18:02??Minix3?project2?文檔.doc
?????文件???????3248??2010-05-05?19:02??src\include\minix\callnr.h
?????文件??????43529??2010-05-05?19:07??src\include\minix\com.h
?????文件??????12348??2010-05-05?19:10??src\include\minix\syslib.h
?????文件???????9847??2010-05-05?21:55??src\include\unistd.h
?????文件???????3221??2010-05-03?16:39??src\kernel\config.h
?????文件??????11556??2010-05-09?15:53??src\kernel\main.c
?????文件??????50345??2010-05-09?17:03??src\kernel\proc.c
?????文件??????10784??2010-05-05?20:28??src\kernel\proc.h
?????文件???????1380??2010-05-10?17:38??src\kernel\system\do_chrt.c
?????文件???????1384??2010-05-10?17:37??src\kernel\system\do_chrt.c.bak
?????文件???????3180??2010-05-03?16:02??src\kernel\system\do_exit.c
?????文件???????3657??2010-05-03?22:00??src\kernel\system\Makefile
?????文件??????22847??2010-05-03?16:41??src\kernel\system.c
?????文件???????5750??2010-05-03?16:38??src\kernel\system.h
?????文件???????1555??2010-05-03?22:50??src\lib\posix\Makefile.in
?????文件????????169??2010-05-09?15:23??src\lib\posix\_chrt.c
?????文件???????1428??2010-05-04?11:04??src\lib\syslib\Makefile.in
?????文件????????457??2010-05-09?15:22??src\lib\syslib\sys_chrt.c
?????文件??????18420??2010-05-08?11:09??src\servers\pm\misc.c
?????文件???????3471??2010-05-03?22:15??src\servers\pm\proto.h
?????文件???????3885??2010-05-07?16:38??src\servers\pm\table.c
?????目錄??????????0??2010-05-06?20:37??src\include\minix
?????目錄??????????0??2010-05-10?17:38??src\kernel\system
?????目錄??????????0??2010-05-06?14:20??src\lib\posix
?????目錄??????????0??2010-05-06?20:55??src\lib\syslib
?????目錄??????????0??2010-05-06?20:42??src\servers\pm
?????目錄??????????0??2010-05-06?14:50??src\include
?????目錄??????????0??2010-05-09?17:05??src\kernel
?????目錄??????????0??2010-05-06?14:20??src\lib
............此處省略5個文件信息
評論
共有 條評論