📄 dllist-driver.cc
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -