nachos01.docVIP

  • 18
  • 0
  • 约6.62千字
  • 约 9页
  • 2016-08-08 发布于河南
  • 举报
nachos01

实验一 体验Nachos下的并发程序设计 一、小组成员及分工 汪于波(23020078104116):main.cc的修改、threadtest.cc的修改和实验报告 潘羽龙(23020078104100):dllist.cc的实现 吴道裕(23020078104132):dllist-driver.cc的实现和实验报告的完成 谭原(23020078104111):dllist.h的实现和Mmon的修改 二、实验目的 对nachos进行熟悉,并初步体验nachos下的并发程序设计。 三、实验内容 1.安装nachos; 2.用C++实现双向有序链表; 3.在nachos系统中使用你所写的链表程序并演示一些并发错误 四、实验步骤 1.首先明确Nachos各部分的关系 在~/nachos/nachos-3.4/code/下有一个Mmon,在code/的各个子目录下的Makefile都继承这个Mmon。通过阅读main.cc知道,main函数一旦启动,立即调用Initialize,进行初始化的操作,然后对相应的参数进行处理,之后在分模块进行相应模块下的函数调用,执行相应的功能。 2.编写相应的函数 实验要求利用对双向链表的操作来演示并发程序可能出现的错误,首先需要实现双向链表dllist,包括dllist.h,dllist.cc。当DLList类实现后,需要编写链表驱动函数Insert和Remove来对链表进行驱动。通过改写threadtest.cc,使得多个线程在没有进行任何互斥操作的情况下对同一数据结构进行操作,在这个过程中就可能出现并发错误。改写Mmon和main.cc。 3.详细设计 a)dllist.h(~/nachos/nachos-3.4/code/threads/) 类DLList的声明 class DLLElement { public: DLLElement(void *itemPtr,int sortKey);//initialize a list element DLLElement *next;//next element on list DLLElement *prev;//previous element on list int key; void *item; }; class DLList { public: DLList();//initialize the list DLList(int type); ~DLList();//de-allocate the list void Prepend(void *item);//add to head of list void Append(void *item);//add to tail of list void *Remove(int *keyPtr);//remove frome head of list bool IsEmpty();//return true if list has elements void SortedInsert(void *item,int sortKey); void *SortedRemove(int sortKey);//remove first item with key==sortKey private: DLLElement *first; DLLElement *last; int yield_type;//different yield positon }; b) dllist.cc(~/nachos/nachos-3.4/code/threads/) 类DLList方法的实现,其中核心操作Remove,SortedInsert。 //---------------------------------------------------------------------- // DLList::Remove // Remove the first item from the front of the dllist. // // Returns: // Pointer to removed item, NULL if nothing on the list. //---------------------------------------------------------------------- void * DLList::Remove(int *keyPtr) { DLLElement *temp; void *tempitem = NULL; if(IsEmpty()) { keyPt

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档