东北大学秦皇岛分校操作系统课设报告.doc
《东北大学秦皇岛分校操作系统课设报告.doc》由会员分享,可在线阅读,更多相关《东北大学秦皇岛分校操作系统课设报告.doc(16页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
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
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 东北大学 秦皇岛 分校 操作系统 报告
限制150内