資源簡(jiǎn)介
一個(gè)操作系統(tǒng)原型系統(tǒng)的實(shí)現(xiàn)
(實(shí)現(xiàn)操作系統(tǒng)的3個(gè)主要功能:進(jìn)程管理、內(nèi)存(存儲(chǔ))管理、文件管理)
代碼片段和文件信息
#define?HAVE_STRUCT_TIMESPEC
#include
#include
#include
#include
#include
#include
#include?
#include?“memory.h“
#include?“file_system.h“
#include?“memory_buddy.h“
sem_t?block_sum?file_sum?pro_sumone?pro_sumtwo?block_sumtwo;
#pragma?warning(disable:?4996)?
#pragma?comment(lib?“pthreadVC2.lib“)
int?pid;
int?r_time;
int?priority;
int?lock?=?1;
int?flag?=?0;
int?process_choice?=?0;
#define?block?0???????//阻塞
#define?ready?1???????//就緒
#define?running?2?????//運(yùn)行
#define?finish?3??????//完成
#define?time_slice_1?100
#define?time_slice_2?500
int?input_lock?=?0;
int?Pid_count?=?0;
int?memory_choice;???//選擇內(nèi)存的參數(shù)?
int?memory_pid[3];???//連接內(nèi)存的參數(shù)?
clock_t?Current_time?start_time?end_time;
FILE*?fp;
//進(jìn)程結(jié)構(gòu)的定義,以及鏈表指針的定義
struct?process?{
int?Pid;
int?Time;
int?state;
int?Priority;
int?memory_needs;
int?memory_state?=?0;???//判斷內(nèi)存是否足夠
int?device1;????????//所需設(shè)備
int?device2;
int?device3;
int?device4;
struct?FileCB?*FCB;
struct?node?*memory;
struct?process*?next;
struct?process*?pre;
};
process?*R_first?=?NULL?*R_last?=?NULL?*R_current?=?NULL?*R_temp?=?NULL;
process?*B_first?=?NULL?*B_last?=?NULL?*B_current?=?NULL?*B_temp?=?NULL;
process?*RR1_first?=?NULL?*RR1_last?=?NULL;
process?*RR2_first?=?NULL?*RR2_last?=?NULL;
process?*RR3_first?=?NULL?*RR3_last?=?NULL?*RR_temp;
process?*file_first?=?NULL?*file_last?=?NULL;
process?*file_temp?=?NULL;
FileCB?*file?*F_temp;
void?Clear_queue1()
{
RR1_first?=?R_first;
RR1_last?=?R_last;
R_first?=?NULL;
R_last?=?NULL;
}
void?Clear_queue2()
{
R_temp?=?RR1_first;
while?(R_temp?!=?NULL)
{
if?(R_first?=?NULL)
{
R_first?=?R_temp;
R_last?=?R_temp;
R_temp->next?=?NULL;
R_temp->pre?=?NULL;
}
else
{
R_temp->pre?=?R_last;
R_temp->next?=?NULL;
R_last->next?=?R_temp;
R_last?=?R_temp;
}
}
R_temp?=?RR2_first;
while?(R_temp?!=?NULL)
{
if?(R_first?=?NULL)
{
R_first?=?R_temp;
R_last?=?R_temp;
R_temp->next?=?NULL;
R_temp->pre?=?NULL;
}
else
{
R_temp->pre?=?R_last;
R_temp->next?=?NULL;
R_last->next?=?R_temp;
R_last?=?R_temp;
}
}
R_temp?=?RR3_first;
while?(R_temp?!=?NULL)
{
if?(R_first?=?NULL)
{
R_first?=?R_temp;
R_last?=?R_temp;
R_temp->next?=?NULL;
R_temp->pre?=?NULL;
}
else
{
R_temp->pre?=?R_last;
R_temp->next?=?NULL;
R_last->next?=?R_temp;
R_last?=?R_temp;
}
}
RR1_first?=?NULL;
RR1_last?=?NULL;
RR2_first?=?NULL;
RR2_last?=?NULL;
RR3_first?=?NULL;
RR3_last?=?NULL;
}
//設(shè)備
struct?device?{
int?number;
};
device?device_one?device_two?device_three?device_four;
//初始化函數(shù)
void?init_devices()
{
device_one.number?=?1;
device_two.number?=?2;
device_three.number?=?3;
device_four.number?=?4;
sem_init(&block_sum?0?1);
sem_init(&file_sum?0?1);
sem_
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2018-05-15?18:40??os\
?????目錄???????????0??2018-05-15?17:44??os\.vs\
?????目錄???????????0??2018-05-15?17:44??os\.vs\os\
?????目錄???????????0??2018-05-15?19:28??os\.vs\os\v15\
?????文件???????40448??2018-05-15?19:28??os\.vs\os\v15\.suo
?????文件????34275328??2018-05-15?19:28??os\.vs\os\v15\Browse.VC.db
?????目錄???????????0??2018-05-15?17:46??os\.vs\os\v15\ipch\
?????目錄???????????0??2018-05-15?19:26??os\.vs\os\v15\ipch\AutoPCH\
?????目錄???????????0??2018-05-15?19:26??os\.vs\os\v15\ipch\AutoPCH\714071ffc632f29e\
?????文件????44433408??2018-05-15?19:26??os\.vs\os\v15\ipch\AutoPCH\714071ffc632f29e\源.ipch
?????目錄???????????0??2018-05-15?18:07??os\Debug\
?????文件??????101376??2018-05-15?18:58??os\Debug\os.exe
?????文件??????611172??2018-05-15?18:58??os\Debug\os.ilk
?????文件?????1003520??2018-05-15?18:58??os\Debug\os.pdb
?????目錄???????????0??2018-05-15?19:28??os\os\
?????目錄???????????0??2018-05-15?18:58??os\os\Debug\
?????文件????????3839??2018-05-15?18:58??os\os\Debug\os.log
?????目錄???????????0??2018-05-15?18:58??os\os\Debug\os.tlog\
?????文件?????????770??2018-05-15?18:58??os\os\Debug\os.tlog\CL.command.1.tlog
?????文件???????28204??2018-05-15?18:58??os\os\Debug\os.tlog\CL.read.1.tlog
?????文件?????????456??2018-05-15?18:58??os\os\Debug\os.tlog\CL.write.1.tlog
?????文件????????1014??2018-05-15?18:58??os\os\Debug\os.tlog\li
?????文件????????3664??2018-05-15?18:58??os\os\Debug\os.tlog\li
?????文件?????????344??2018-05-15?18:58??os\os\Debug\os.tlog\li
?????文件?????????203??2018-05-15?18:58??os\os\Debug\os.tlog\os.lastbuildstate
?????文件??????265216??2018-05-15?18:58??os\os\Debug\vc141.idb
?????文件??????159744??2018-05-15?18:58??os\os\Debug\vc141.pdb
?????文件??????180322??2018-05-15?18:58??os\os\Debug\源.obj
?????文件?????????163??2018-05-15?19:11??os\os\FCBba
?????文件???????24244??2018-05-15?18:58??os\os\file_system.h
?????文件????????8843??2018-05-15?19:20??os\os\fun.txt
............此處省略10個(gè)文件信息
評(píng)論
共有 條評(píng)論