《操作系统》实验教学大纲 (一)课程简介 操作系统是计算机科学技术、信息管理、软件工程等专业的一门专业基础课,他的先导 课程有:数据结构、计算机原理、程序设计等课程:操作系统实验课是该门课程的重要组成 部分。 (二)教学目的 通过本实验课的学习,目的使学生能加深操作系统中基本概念的理解,同时对操作系统 中的常用算法的实现具有更直观的理解 (三)使用教材 本课程理论课的教材为:《计算机操作系统》,(修订版),汤子瀛、哲风屏、汤小丹编著, 西安电子科技出版社,2002.8 (四)考核方式 本实验的考核以所提交的上机作业为考核依据,实验课程的成绩不单独计算,它占总成 绩的20%。 (五)实验课内容 实验编号01201001 实验名称用汇编语言写出P、V操作原语 实验內容编程 实验类型设计 实验学时2学时 实验目的掌握P、V操作的设计方法 实验要求必修 实验编号01201002 实验名称用高级语言写出基于消息传递的进程通讯方法 实验内容编程 实验类型设计 实验学时2学时 实验目的掌握消息传递和同步 实验要求必修 实验编号01201003 实验名称用高级语言写出银行家算法 实验內容编程 实验类型设计 实验学时2学时 实验目的掌握避免死锁的方法 实验要求必修 实验编号01201004 实验名称用高级语言写出按最先适应算法的存储器管理程序 实验内容编程 实验类型设计
《操作系统》实验教学大纲 (一) 课程简介 操作系统是计算机科学技术、信息管理、软件工程等专业的一门专业基础课,他的先导 课程有:数据结构、计算机原理、程序设计等课程;操作系统实验课是该门课程的重要组成 部分。 (二) 教学目的 通过本实验课的学习,目的使学生能加深操作系统中基本概念的理解,同时对操作系统 中的常用算法的实现具有更直观的理解。 (三) 使用教材 本课程理论课的教材为:《计算机操作系统》,(修订版),汤子瀛、哲风屏、汤小丹编著, 西安电子科技出版社,2002.8 (四) 考核方式 本实验的考核以所提交的上机作业为考核依据,实验课程的成绩不单独计算,它占总成 绩的 20%。 (五) 实验课内容 实验编号 01201001 实验名称 用汇编语言写出 P、V 操作原语 实验内容 编程 实验类型 设计 实验学时 2 学时 实验目的 掌握 P、V 操作的设计方法 实验要求 必修 实验编号 01201002 实验名称 用高级语言写出基于消息传递的进程通讯方法 实验内容 编程 实验类型 设计 实验学时 2 学时 实验目的 掌握消息传递和同步 实验要求 必修 实验编号 01201003 实验名称 用高级语言写出银行家算法 实验内容 编程 实验类型 设计 实验学时 2 学时 实验目的 掌握避免死锁的方法 实验要求 必修 实验编号 01201004 实验名称 用高级语言写出按最先适应算法的存储器管理程序 实验内容 编程 实验类型 设计
实验学时2学时 实验目的掌握分区管理的实现方法 实验要求必修 实验编号01201005 实验名称用高级语言写出改进的LRU算法的程序实现 实验内容编程 实验类型设计 实验学时2学时 实验目的掌握一种淘汰算法 实验要求必修 实验编号01201006 实验名称用高级语言写出事务实现的模拟程序 实验内容编程 实验类型设计 实验学时2学时 实验目的掌握RED()和UN0()过程的设计 实验要求必修 说明:本课程的所有实验约需要16~18个学时,实验全部在微机上实现,所以上表中未列 出实验所需的设备:上机时间从第6周到第16周 早上看了水晶龙的一个undo的例子,其中虽然有一些 command模式的思想,但是用的好像不够正宗。其 实用 command模式实现undo和redo应该还是比较容易的,做个例子练练手吧: <IDOC TYPE HTML PUBLIC"-M3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> test command </TITLE> <META NAME="Author "CoNTENT="emu"> <SCRIPT LANGUAGE="JavaScript"> var action Stack=U∥操作栈
实验学时 2 学时 实验目的 掌握分区管理的实现方法 实验要求 必修 实验编号 01201005 实验名称 用高级语言写出改进的 LRU 算法的程序实现 实验内容 编程 实验类型 设计 实验学时 2 学时 实验目的 掌握一种淘汰算法 实验要求 必修 实验编号 01201006 实验名称 用高级语言写出事务实现的模拟程序 实验内容 编程 实验类型 设计 实验学时 2 学时 实验目的 掌握 REDO()和 UNDO()过程的设计 实验要求 必修 说明:本课程的所有实验约需要 16~18 个学时,实验全部在微机上实现,所以上表中未列 出实验所需的设备;上机时间从第 6 周到第 16 周 早上看了水晶龙的一个 undo 的例子,其中虽然有一些 command 模式的思想,但是用的好像不够正宗。其 实用 command 模式实现 undo 和 redo 应该还是比较容易的,做个例子练练手吧: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> test command </TITLE> <META NAME="Author" CONTENT="emu"> <SCRIPT LANGUAGE="JavaScript"> <!-- var actionStack = [];//操作栈
var actionIndex=0操作栈中当前操作的指针 command对象基类 function Base Actionot BaseAction prototype exec=function(( action StacklactionIndex++]=this: action Stack length=actionIndex BaseAction prototype undo=function( alert(“此操作未定义相应的undo操作 Base Action. prototype redo=functiond alert(“此操作未定义相应的redo操作") ∥--move操作的 com mand对象 function Move Action(elml is oldX= elm. oldX this oldY= elm.oldY this newX= elm .newX this newY= elm. newY this source Element =el this status ="done Move Action. prototype= new BaseAction0: Move Action. prototype undo=functional if (this status I="done )return
var actionIndex = 0;//操作栈中当前操作的指针 //----------------------- command 对象基类 ------------------------------ function BaseAction(){ } BaseAction.prototype.exec=function(){ actionStack[actionIndex++] = this; actionStack.length = actionIndex; } BaseAction.prototype.undo=function(){ alert("此操作未定义相应的 undo 操作"); } BaseAction.prototype.redo=function(){ alert("此操作未定义相应的 redo 操作"); } //----------------------- move 操作的 command 对象 ------------------------------ function MoveAction(elm){ this.oldX = elm.oldX; this.oldY = elm.oldY; this.newX = elm.newX; this.newY = elm.newY; this.sourceElement = elm; this.status = "done"; } MoveAction.prototype = new BaseAction(); MoveAction.prototype.undo=function(){ if (this.status != "done") return;
this source Element style left= this. oldX this source Element style. top= this oldY; this status ="undone Move Action. prototype redo=function if this status l="undone")retum this source Element style left= this newX this source Element style top=this newY this status =done change操作的 com mand对象 function ChangeAction(elm) this source Element=elm lis oldvalue elm defaultvalue lis. newvalue =elm value elm defaultvalue =elm value this status ="done ChangeAction prototype= new BaseActiono ChangeAction prototype undo = function if(this status I="done )return lis source Element value= this source Element defaultvalue this oldValue this status ="undone ChangeAction prototype redo =function( if(this status l="undone")return s source Element value this. new Value
this.sourceElement.style.left = this.oldX; this.sourceElement.style.top = this.oldY; this.status = "undone"; } MoveAction.prototype.redo=function(){ if (this.status != "undone") return; this.sourceElement.style.left = this.newX; this.sourceElement.style.top = this.newY; this.status = "done"; } //----------------------- change 操作的 command 对象 ------------------------------ function ChangeAction(elm){ this.sourceElement = elm; this.oldValue = elm.defaultValue; this.newValue = elm.value; elm.defaultValue = elm.value; this.status = "done"; } ChangeAction.prototype = new BaseAction(); ChangeAction.prototype.undo = function(){ if (this.status != "done") return; this.sourceElement.value = this.sourceElement.defaultValue = this.oldValue; this.status = "undone"; } ChangeAction.prototype.redo = function(){ if (this.status != "undone") return; this.sourceElement.value = this.newValue;
this status =done 全局函数 function undoot f(actionIndex>OX action Stack[--actionIndex] undo function redoot if (actionIndex<action Stack length) action StacklactionIndex++] redo: function checkMouse MoveD if (window. active Element) var elm window active Element elm style left=event. X-elm. inner elm. style. top= event. y-elm inner function releaseMouseO if (window. active Element) active ElementnewX=event x-active Element inner activeElement new Y=event y-activeElement inner ew Move Action(active Element). execo
this.status = "done"; } //--------------------- 全局函数 ---------------------------- function undo(){ if (actionIndex>0){ actionStack[--actionIndex].undo(); } } function redo(){ if (actionIndex<actionStack.length){ actionStack[actionIndex++].redo(); } } function checkMouseMove(){ if (window.activeElement){ var elm = window.activeElement; elm.style.left = event.x-elm.innerX; elm.style.top = event.y-elm.innerY; } } function releaseMouse(){ if (window.activeElement){ activeElement.newX = event.x-activeElement.innerX; activeElement.newY = event.y-activeElement.innerY; new MoveAction(activeElement).exec();