dllist-driver.cc

来自「这是一个关于操作系统进程调度的实验」· CC 代码 · 共 54 行

CC
54
字号
#include <cstdio>#include <cstdlib>#include <ctime>#include "system.h"#include "dllist.h"DLList L;void  Begin(int n ){	void * temp;	int key, i;		srand( time(0) );	for( i = 1; i <= Node_num; i++ )	{  		temp = new int( rand() ) ;		temp = ( void * )( (int)temp % 10000 );		key = (int)temp % 1000;		//L.SortedInsert( temp, key );		printf("Thread %d: Inssert:%d, Item:%d\n", n, key, (int)temp );		 L.SortedInsert( temp, key );		if( Flag == 1  )		{//&& rand() % 2 == 0			printf("\tBegin interrupt!\n");			currentThread->Yield();		}	}}void End( int n ){	int key;	void * temp;        int i=0;		while( !L.IsEmpty()&& i!=Node_num )	{		if( ( temp = L.Remove(& key ) ) )			printf("Thread %d: Removed:%d, Item:%d\n", n, key, (int)temp );		i++;                if( Flag == 2 )		{			printf("End interrupt!\n");			currentThread->Yield();		}			}}

⌨️ 快捷键说明

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