⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dllist-driver.cc

📁 nachos下线程与同步的实验
💻 CC
字号:
#include<iostream.h>
#include<time.h>
#include "thread.h"
#include "system.h"
#include "dllist.h"


//Thread *currenThread;
extern  int testnum;
void Insertlist(int n,DouList *list,int which)
{
	cout << which << "go into Insertlist" << endl;
	
	int i,h;

        int A1[5]={4,7,2,8,9};

        int B1[5]={1,5,9,13,17};

        int B2[5]={2,4,8,16,32};
               
        int A2[5]={1,5,10,15,20};

	for(i = 1; i <= n; i++)
	{  
              	if(testnum==1)
            	{
            
             		if(which==0)
            
               		h=A1[i-1];
         
             	else
                  	
			h=A2[i-1];
           	}
          	
		else if(testnum==2||testnum==3||testnum==4)
          	{
            	
			if(which==0)

                	h=B1[i-1];

     		        else
                	
			h=B2[i-1];
         	}

	 //	h = rand()%100 + 1;
	 //	if(which == 1)
	 //		h *= -1;
	 //cout<<"Thread "<<which<<" insert Num "<<i<<" to the list: "<<h<<endl;
		
		list->Insert(new DouListElement(h),which,i);
            	
	 	list->PrintList();
	}//for
}

void Removelist(int n,DouList *list,int which)
{
	int i;

	for(i = 1; i <= n; i++)
	{
	 //	cout<<"Thread "<<which<<" Delete Num "<<i<<" of the list"<<endl;

		list->FistDelete(which,i);

		list->PrintList();
	}
}

/*int main(void)
{
	DouList list;
	Insertlist(5,&list,0);
	Insertlist(5,&list,1);
	Removelist(6,&list,1);
	Removelist(4,&list,0);
	return 1;
}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -