东北大学秦皇岛分校操作系统课设报告.doc

上传人:飞****2 文档编号:56408424 上传时间:2022-11-01 格式:DOC 页数:16 大小:148.50KB
返回 下载 相关 举报
东北大学秦皇岛分校操作系统课设报告.doc_第1页
第1页 / 共16页
东北大学秦皇岛分校操作系统课设报告.doc_第2页
第2页 / 共16页
点击查看更多>>
资源描述

《东北大学秦皇岛分校操作系统课设报告.doc》由会员分享,可在线阅读,更多相关《东北大学秦皇岛分校操作系统课设报告.doc(16页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、 东北大学秦皇岛分校计算机与通信工程学院计算机操作系统课程设计设计题目:进程管理器专业名称计算机科学与技术班级学号xxxx学生姓名xxxx指导教师xxxxx设计时间2014-12-292015-1-15课程设计任务书专业:计算机科学与技术 学号: 学生姓名(签名):设计题目1、高优先权调度算法的模拟2、进程管理器的模拟实现二、主要内容1、目的:编程模拟实现进程管理器,加深对进程、程序概念掌握. 2、进程管理器主界面如下:(1)源代码: Form1.csusing System;using System.Collections.Generic;using System.ComponentMode

2、l;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Management;using System.Diagnostics;namespace WindowsApplication1 public partial class Form1 : Form public Form1() InitializeComponent(); this.listProcesses.MultiSelect = false; this.listProcesses.View

3、 = View.Details; this.listProcesses.Columns.Add(pname,(int)CreateGraphics().MeasureString( aaaaaaaaaaaaaaaaaaaaaa,Font).Width); this.listProcesses.Columns.Add(pID, (int)CreateGraphics().MeasureString( 0, Font).Width); this.listProcesses.Columns.Add(username, (int)CreateGraphics().MeasureString( aaaa

4、aaaaaaaaaaaaaaaaa, Font).Width); this.listProcesses.Columns.Add(priority, (int)CreateGraphics().MeasureString( aaaaaaaaa, Font).Width); this.listProcesses.Columns.Add(Memory usage, (int)CreateGraphics().MeasureString( 0000,Font).Width); private void Form1_Load(object sender, EventArgs e) RefreshList

5、(); private void RefreshList() Process processes; processes = Process.GetProcesses(); this.listProcesses.Items.Clear(); foreach (Process instance in processes) ListViewItem lvi = new ListViewItem(instance.ProcessName); lvi.SubItems.Add(FormatProcessID(instance.Id); lvi.SubItems.Add(GetProcessUserNam

6、e(instance.Id); lvi.SubItems.Add(instance.BasePriority.ToString(); lvi.SubItems.Add(FormatMemorySize(instance.WorkingSet64); string strToolTip = null; ProcessModuleCollection modules; if (instance.ProcessName.CompareTo(System) != 0 | instance.ProcessName.CompareTo(Idle) != 0) try /当进程不充允枚举模块时会产生异常 m

7、odules = instance.Modules; foreach (ProcessModule aModule in modules) strToolTip += aModule.ModuleName; strToolTip += ; ; catch (System.ComponentModel.Win32Exception) lvi.ToolTipText = strToolTip; this.listProcesses.Items.Add(lvi); /格式化内存字符串 private string FormatMemorySize(long lMemorySize) return S

8、tring.Format(0,8:N0 K, lMemorySize / 1000); private string FormatProcessID(int id) return String.Format(0,8,id); private static string GetProcessUserName(int pID) string text1 = null; SelectQuery query1 = new SelectQuery(Select * from Win32_Process WHERE processID= + pID); ManagementObjectSearcher s

9、earcher1 = new ManagementObjectSearcher(query1); try foreach (ManagementObject disk in searcher1.Get() ManagementBaseObject inPar = null; ManagementBaseObject outPar = null; inPar = disk.GetMethodParameters(GetOwner); outPar = disk.InvokeMethod(GetOwner, inPar, null); text1 = outParUser.ToString();

10、break; catch text1 = SYSTEM; return text1; private void StopProcess_Click(object sender, EventArgs e) Process process = Process.GetProcessById( int.Parse(this.listProcesses.SelectedItems0.SubItems1.Text); process.Kill(); RefreshList(); /释放进程的资源 private void Refresh_Click(object sender, EventArgs e)

11、RefreshList(); private void CreateProcess_Click(object sender, EventArgs e) DialogBox dlg = new DialogBox(); if (dlg.ShowDialog() = DialogResult.OK) try Process.Start(dlg.FileName); catch (System.ComponentModel.Win32Exception) MessageBox.Show(String.Format(cant find the files 0,please make sure of t

12、he name of files then try again。n press start to search files,dlg.FileName); Form1.Designer.csnamespace WindowsApplication1 partial class Form1 / / 必需的设计器变量。 / private System.ComponentModel.IContainer components = null; / / 清理所有正在使用的资源。 / / 如果应释放托管资源,为 true;否则为 false。 protected override void Dispose

13、(bool disposing) if (disposing & (components != null) components.Dispose(); base.Dispose(disposing); #region Windows 窗体设计器生成的代码 / / 设计器支持所需的方法 / 使用代码编辑器修改此方法的内容。 / private void InitializeComponent() this.listProcesses = new System.Windows.Forms.ListView(); this.StopProcess = new System.Windows.Forms

14、.Button(); this.btnRefresh = new System.Windows.Forms.Button(); this.CreateProcess = new System.Windows.Forms.Button(); this.SuspendLayout(); / / listProcesses / this.listProcesses.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.

15、Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right); this.listProcesses.Location = new System.Drawing.Point(-1, 10); this.listProcesses.Name = listProcesses; this.listProcesses.ShowItemToolTips = true; this.listProcesses.Size = new System.Drawing.Size(363, 29

16、7); this.listProcesses.TabIndex = 0; this.listProcesses.UseCompatibleStateImageBehavior = false; / / StopProcess / this.StopProcess.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); this.StopProcess.Location = new System

17、.Drawing.Point(274, 313); this.StopProcess.Name = StopProcess; this.StopProcess.Size = new System.Drawing.Size(100, 23); this.StopProcess.TabIndex = 1; this.StopProcess.Text = StopProcess; this.StopProcess.UseVisualStyleBackColor = true; this.StopProcess.Click += new System.EventHandler(this.StopPro

18、cess_Click); / / btnRefresh / this.btnRefresh.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left); this.btnRefresh.Location = new System.Drawing.Point(12, 313); this.btnRefresh.Name = btnRefresh; this.btnRefresh.Size = new S

19、ystem.Drawing.Size(75, 23); this.btnRefresh.TabIndex = 2; this.btnRefresh.Text = Reflesh(&R); this.btnRefresh.UseVisualStyleBackColor = true; this.btnRefresh.Click += new System.EventHandler(this.Refresh_Click); / / CreateProcess / this.CreateProcess.Anchor = System.Windows.Forms.AnchorStyles.Bottom

20、; this.CreateProcess.Location = new System.Drawing.Point(141, 313); this.CreateProcess.Name = CreateProcess; this.CreateProcess.Size = new System.Drawing.Size(100, 23); this.CreateProcess.TabIndex = 3; this.CreateProcess.Text = CreateProcess; this.CreateProcess.UseVisualStyleBackColor = true; this.C

21、reateProcess.Click += new System.EventHandler(this.CreateProcess_Click); / / Form1 / this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(364, 344); this.Controls.Add(this.CreateProcess);

22、 this.Controls.Add(this.btnRefresh); this.Controls.Add(this.StopProcess); this.Controls.Add(this.listProcesses); this.Name = Form1; this.Text = Process Manager; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); #endregion private System.Windows.Forms.ListView listProce

23、sses; private System.Windows.Forms.Button StopProcess; private System.Windows.Forms.Button btnRefresh; private System.Windows.Forms.Button CreateProcess; DialogBox.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;usi

24、ng System.Windows.Forms;namespace WindowsApplication1 public partial class DialogBox : Form public DialogBox() InitializeComponent(); StartPosition = FormStartPosition.CenterParent; this.label1.Text = open file.; private void DialogBox_Load(object sender, EventArgs e) private void OK_Click(object se

25、nder, EventArgs e) DialogResult = DialogResult.OK; private void Cancel_Click(object sender, EventArgs e) DialogResult = DialogResult.Cancel; private void btnShow_Click(object sender, EventArgs e) OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = program|*.exe| + all files|*.*; if (dlg.ShowDial

26、og() = DialogResult.OK) boBox1.Text = dlg.FileName; public string FileName get return boBox1.Text; DialogBox.Designer.csnamespace WindowsApplication1 partial class DialogBox / / 必需的设计器变量。 / private System.ComponentModel.IContainer components = null; / / 清理所有正在使用的资源。 / / 如果应释放托管资源,为 true;否则为 false。 p

27、rotected override void Dispose(bool disposing) if (disposing & (components != null) components.Dispose(); base.Dispose(disposing); #region Windows 窗体设计器生成的代码 / / 设计器支持所需的方法 / 使用代码编辑器修改此方法的内容。 / private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.C

28、omponentModel.ComponentResourceManager(typeof(DialogBox); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); boBox1 = new System.Windows.Forms.ComboBox(); this.OK = new System.Windows.Forms.Button(

29、); this.Cancel = new System.Windows.Forms.Button(); this.btnShow = new System.Windows.Forms.Button(); (System.ComponentModel.ISupportInitialize)(this.pictureBox1).BeginInit(); this.SuspendLayout(); / / pictureBox1 / this.pictureBox1.Image = (System.Drawing.Image)(resources.GetObject(pictureBox1.Imag

30、e); this.pictureBox1.Location = new System.Drawing.Point(12, 12); this.pictureBox1.Name = pictureBox1; this.pictureBox1.Size = new System.Drawing.Size(32, 35); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; / / label1 / this.label1.AutoSize = true; this.label1.Location = new System

31、.Drawing.Point(67, 16); this.label1.Name = label1; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 1; / / label2 / this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(10, 64); this.label2.Name = label2; this.label2.Size = new System.Drawing.Size(53,

32、 12); this.label2.TabIndex = 2; this.label2.Text = Open:; / / comboBox1 / boBox1.FormattingEnabled = true; boBox1.Location = new System.Drawing.Point(69, 61); boBox1.Name = comboBox1; boBox1.Size = new System.Drawing.Size(242, 20); boBox1.TabIndex = 3; / / OK / this.OK.Location = new System.Drawing.Point(74, 98); this.OK.Name = OK; this.OK.Size = new System.Drawing.Size(75, 23); this.OK.TabIndex = 4; this.OK.Text = Enter; this.OK.UseVisualStyleBackColor = true; this.OK.Click += new System.EventHandler(this.OK_Click); / /

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁