-
大小: 344KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-05-19
- 語言: C#
- 標(biāo)簽: 操作系統(tǒng)??進(jìn)程管理??
資源簡介
os實(shí)驗(yàn),采用C#語言模擬進(jìn)程管理問題,采用了時(shí)間片輪轉(zhuǎn)調(diào)度、先來先服務(wù)、短進(jìn)程優(yōu)先調(diào)度三種算法模擬進(jìn)程調(diào)度問題,可以時(shí)時(shí)查看進(jìn)程調(diào)度情況和資源變化情況

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Collections;
using?System.IO;
namespace?os_test2
{
????public?partial?class?ProManage?:?Form
????{
????????public?ProManage()
????????{
????????????InitializeComponent();
????????????this.InitForm();
????????}
????????ArrayList?hAll?=?new?ArrayList();??//存儲(chǔ)所有進(jìn)程隊(duì)列
????????ArrayList?hReady?=?new?ArrayList();//用于存放就緒隊(duì)列
????????ArrayList?hBlock?=?new?ArrayList();//用于存放阻塞隊(duì)列
????????int?m?n?r?a?b?c?h?=?0?timecount=0;
????????public?void?InitForm()//初始化初始進(jìn)程信息
????????{
????????????txtPCount.Text?=?“5“;
????????????txtInitPCount.Text?=?“3“;
????????????txtACount.Text?=?“10“;
????????????txtBCount.Text?=?“10“;
????????????txtCCount.Text?=?“10“;
????????????txtTimelen.Text?=?“500“;
????????}
????????//短進(jìn)程優(yōu)先調(diào)度初始化進(jìn)程
????????public?void?InitPcbAndInsertSPF()
????????{
????????????int?tmp?=?0;
????????????object?p0?=?null;
????????????ArrayList?temp?=?new?ArrayList();
????????????Random?ran?=?new?Random();//用于產(chǎn)生隨機(jī)數(shù)
????????????m?=?Convert.ToInt32(txtPCount.Text.ToString());
????????????n?=?Convert.ToInt32(txtInitPCount.Text.ToString());
????????????a?=?Convert.ToInt32(txtACount.Text.ToString());
????????????b?=?Convert.ToInt32(txtBCount.Text.ToString());
????????????c?=?Convert.ToInt32(txtCCount.Text.ToString());
????????????time?=?Convert.ToInt32(txtTimelen.Text.ToString());
????????????timer1.Interval?=?time;
????????????r?=?m?-?n;
????????????count?=?n;
????????????string?str?=?““;
????????????for?(int?i?=?0;?i?????????????{
????????????????Pcb?p?=?new?Pcb();
????????????????p.Id?=?i?+?1;
????????????????p.Ra?=?ran.Next(a)?+?1;
????????????????p.Rb?=?ran.Next(b)?+?1;
????????????????p.Rc?=?ran.Next(c)?+?1;
????????????????p.Ntime?=?ran.Next(5)?+?1;
????????????????p.Rtime?=?0;
????????????????p.State?=?‘B‘;
????????????????temp.Add(p);
????????????}
????????????for?(int?i?=?0;?i?????????????{
????????????????tmp?=?i;
????????????????for?(int?j?=?i?+?1;?j?????????????????????if?(((Pcb)temp[tmp]).Ntime?>?((Pcb)temp[j]).Ntime)?tmp?=?j;
????????????????if?(i?!=?tmp)
????????????????{
????????????????????p0?=?temp[tmp];
????????????????????temp[tmp]?=?temp[i];
????????????????????temp[i]?=?p0;
????????????????}
????????????}
????????????int?ff?=?0;
????????????for?(int?i?=?0;?i?????????????{
????????????????Pcb?p?=?(Pcb)temp[i];
????????????????if?(p?!=?null)
????????????????{
?????????????????????if?(ff==0&&((a?-?p.Ra)?>=?0)?&&?((b?-?p.Rb)?>=?0)?&&?((c?-?p.Rc)?>=?0))?//如果符合要求寫入就緒隊(duì)列隊(duì)尾(狀態(tài)為W)
????????????????????{
????????????????????????a?=?a?-?p.Ra;??????//當(dāng)前所剩A類資源數(shù)目
????????????????????????b?=?b?-?p.Rb;?????//當(dāng)前所剩B類資源數(shù)目
????????????????????????c?=?c?-?p.Rc;??????//當(dāng)前所剩C類資源數(shù)目
????????????????????????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-11-14?16:40??os_test2\
?????目錄???????????0??2012-11-14?16:40??os_test2\os_test2\
?????文件?????????914??2012-10-10?09:15??os_test2\os_test2.sln
?????文件???????20480??2012-11-09?09:35??os_test2\os_test2.suo
?????目錄???????????0??2012-11-14?16:40??os_test2\os_test2\bin\
?????目錄???????????0??2012-11-14?16:40??os_test2\os_test2\bin\Debug\
?????目錄???????????0??2012-11-14?16:40??os_test2\os_test2\bin\Debug\images\
?????文件???????42464??2009-07-04?14:34??os_test2\os_test2\bin\Debug\images\bg1.jpg
?????文件??????162364??2008-10-02?11:10??os_test2\os_test2\bin\Debug\images\bg2.jpg
?????文件???????69632??2012-11-09?09:13??os_test2\os_test2\bin\Debug\os_test2.exe
?????文件???????52736??2012-11-09?09:13??os_test2\os_test2\bin\Debug\os_test2.pdb
?????文件???????14328??2012-11-09?09:15??os_test2\os_test2\bin\Debug\os_test2.vshost.exe
?????文件?????????490??2009-06-11?05:14??os_test2\os_test2\bin\Debug\os_test2.vshost.exe.manifest
?????文件???????31062??2012-11-09?00:10??os_test2\os_test2\Form1.cs
?????文件???????17143??2012-11-08?23:26??os_test2\os_test2\Form1.Designer.cs
?????文件????????6008??2012-11-08?23:26??os_test2\os_test2\Form1.resx
?????目錄???????????0??2012-11-14?16:40??os_test2\os_test2\obj\
?????目錄???????????0??2012-11-14?16:40??os_test2\os_test2\obj\Debug\
?????文件????????3254??2012-11-09?09:15??os_test2\os_test2\obj\Debug\os_test2.csproj.FileListAbsolute.txt
?????文件?????????891??2012-11-09?09:13??os_test2\os_test2\obj\Debug\os_test2.csproj.GenerateResource.Cache
?????文件???????69632??2012-11-09?09:13??os_test2\os_test2\obj\Debug\os_test2.exe
?????文件?????????180??2012-10-24?00:21??os_test2\os_test2\obj\Debug\os_test2.Form1.resources
?????文件???????52736??2012-11-09?09:13??os_test2\os_test2\obj\Debug\os_test2.pdb
?????文件?????????180??2012-11-09?09:13??os_test2\os_test2\obj\Debug\os_test2.ProManage.resources
?????文件???????43115??2012-10-24?00:21??os_test2\os_test2\obj\Debug\os_test2.Properties.Resources.resources
?????目錄???????????0??2012-10-17?11:25??os_test2\os_test2\obj\Debug\Refactor\
?????目錄???????????0??2012-11-14?16:40??os_test2\os_test2\obj\Debug\TempPE\
?????文件????????4608??2012-10-20?14:10??os_test2\os_test2\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????3948??2012-10-20?14:16??os_test2\os_test2\os_test2.csproj
?????文件????????1991??2012-11-08?23:22??os_test2\os_test2\Pcb.cs
?????文件????????2529??2012-10-10?10:23??os_test2\os_test2\pcb.txt
............此處省略7個(gè)文件信息
評論
共有 條評論