亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 設計報告.txt

?? 主要功能: 1、 包括顧客信息、貨品信息、定單信息的管理。 2、 按月統計銷售業績。 3、 報表設計。 4、 系統維護。
?? TXT
?? 第 1 頁 / 共 4 頁
字號:
void acc_right(void* p)
{
 DWORD m_delay;
 int m_serial;
 int tmp1 , tmp2, rand_num;
 int counter = 0;

//get info from para

 m_serial = ((ThreadInfo*) (p)) -> serial;
 m_delay  = (DWORD) (((ThreadInfo*)(p)) -> delay*INTE_PER_SEC);

 do
 {

  flag[m_serial]=true;
  turn=1-m_serial;
  while (flag[1-m_serial] && turn==1-m_serial);

//begin critical_section

  printf("I am thread  %d , I am doing  %05dth step\n",m_serial,counter);
  tmp1 = accnt1;
  tmp2 = accnt2;
  rand_num = rand();

  accnt1 = tmp1 - rand_num;
  Sleep(m_delay);
  accnt2 = tmp2 + rand_num;
  accnt = accnt1 + accnt2;
//critical_section  end

  flag[m_serial]=false;

  counter++;
  printf("Now the random number is %d ; and accnt1+accnt2 =  %05d\n\n",rand_num,accnt);
 } while (counter<10); 
 printf("At last of thread %d accnt1+accnt2 =  %05d\n",m_serial,accnt);
} //end acc_right

void acc_wrong(void* p)
{
 DWORD m_delay;
 int m_serial;
 int tmp1 , tmp2, rand_num;
 int counter = 0;

//get info from para

 m_serial = ((ThreadInfo*) (p)) -> serial;
 m_delay  = (DWORD) (((ThreadInfo*)(p)) -> delay*INTE_PER_SEC);

 do
 {

//begin critical_section

  printf("I am thread  %d , I am doing  %05dth step\n",m_serial,counter);
  tmp1 = accnt1;
  tmp2 = accnt2;
  rand_num = rand();

  accnt1 = tmp1 - rand_num;
  Sleep(m_delay);
  accnt2 = tmp2 + rand_num;
  accnt = accnt1 + accnt2;
//critical_section  end

  counter++;
  printf("Now the random number is %d ; and accnt1+accnt2 =  %05d\n\n",rand_num,accnt);
 } while (counter<10); 
 printf("At last of thread %d accnt1+accnt2 =  %05d\n",m_serial,accnt);
} //end acc_wrong

任務三  同步對象解決臨界區問題
一、基本信息
實踐題目:同步對象解決臨界區問題-兄弟問題
二、實踐內容簡要描述
實踐目標:
學會使用Win32同步對象(臨界區內核對象、信號量內核對象等);
用同步對象解決臨界區問題-兄弟問題。
實踐內容:
設置競爭條件:
定義兩個全局變量:accnt1和accnt2,初值都為零;
創建兩個線程acc1和acc2;
(1)獲得一個隨機數
(2)從accnt1減去這個隨機數;
(3)將這個隨機數加到accnt2中;
(4)正確的話,accnt1+accnt2=0。
設置條件使其不正確。
用Win32提供的同步對象實現兩個線程的協作,以解決以上臨界區問題,即兄弟問題。
三、實踐報告主要內容
設計思路:
用一個臨界區變量可以實現兩個線程對臨界區的訪問,在每個線程進入臨界區前調用EnterCriticalSection函數申請權限,離開臨界區后調用LeaveCriticalSection函數釋放資源從而讓其他線程可以訪問,這樣可以阻止兩個線程同時處于臨界區。
主要數據結構:
struct ThreadInfo
{
 int serial;
 double delay;
};//存放線程的ID及其執行延時(模擬兄弟在外創業的時間)

/*volatile*/  int accnt1 = 0;  //借款帳戶中金額
/*volatile*/  int accnt2 = 0;  //還款帳戶中金額
/*volatile*/  int accnt;  //借款帳戶與還款帳戶金額總和,應保持為0
CRITICAL_SECTION g_cs; //臨界區變量,用于兩個線程的互斥訪問
主要代碼結構:
do{
entry section
critical section
exit section
remainder section
}while(1);
主要代碼分析:
1.entry section用于在進入臨界區時的等待
EnterCriticalSection(&my_section); 
2.exit section用于離開臨界區后的發送信號的工作,通知另外的線程可以進入臨界區
 LeaveCriticalSection(&my_section);
四、實踐結果
基本數據:
 
源程序代碼行數 完成實踐投入的總時間 資料查閱時間 編程調試時間 源程序文件    
193 0.2小時 0.1小時 0.1小時 ex3.cpp  
測試數據設計:
“ex3.dat”文件內容如下:
 0  1
1  1
2  1
3  1
4  1
測試結果分析:
運行結果圖如下所示:
Now, We begin to read thread Information to thread_info array
I am thread  0 , I am doing  00000th step
I am thread  1 , I am doing  00000th step
Now the random number is 22413 ; and accnt1+accnt2 =  00000
I am thread  2 , I am doing  00000th step
Now the random number is 17802 ; and accnt1+accnt2 =  00000
I am thread  3 , I am doing  00000th step
Now the random number is 5286 ; and accnt1+accnt2 =  00000
I am thread  4 , I am doing  00000th step
Now the random number is 23304 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00001th step
Now the random number is 12270 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00001th step
Now the random number is 12170 ; and accnt1+accnt2 =  00000
I am thread  2 , I am doing  00001th step
Now the random number is 4729 ; and accnt1+accnt2 =  00000
I am thread  3 , I am doing  00001th step
Now the random number is 28247 ; and accnt1+accnt2 =  00000
I am thread  4 , I am doing  00001th step
Now the random number is 3819 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00002th step
Now the random number is 2578 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00002th step
Now the random number is 21931 ; and accnt1+accnt2 =  00000
I am thread  2 , I am doing  00002th step
Now the random number is 170 ; and accnt1+accnt2 =  00000
I am thread  3 , I am doing  00002th step
Now the random number is 18300 ; and accnt1+accnt2 =  00000
I am thread  4 , I am doing  00002th step
Now the random number is 2054 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00003th step
Now the random number is 538 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00003th step
Now the random number is 12469 ; and accnt1+accnt2 =  00000
I am thread  2 , I am doing  00003th step
Now the random number is 7825 ; and accnt1+accnt2 =  00000
I am thread  3 , I am doing  00003th step
Now the random number is 14181 ; and accnt1+accnt2 =  00000
I am thread  4 , I am doing  00003th step
Now the random number is 5984 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00004th step
Now the random number is 17150 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00004th step
Now the random number is 15529 ; and accnt1+accnt2 =  00000
At last of thread 0 accnt1+accnt2 =  00000
I am thread  2 , I am doing  00004th step
Now the random number is 31878 ; and accnt1+accnt2 =  00000
At last of thread 1 accnt1+accnt2 =  00000
I am thread  3 , I am doing  00004th step
Now the random number is 3842 ; and accnt1+accnt2 =  00000
At last of thread 2 accnt1+accnt2 =  00000
I am thread  4 , I am doing  00004th step
Now the random number is 5953 ; and accnt1+accnt2 =  00000
At last of thread 3 accnt1+accnt2 =  00000
Now the random number is 23968 ; and accnt1+accnt2 =  00000
At last of thread 4 accnt1+accnt2 =  00000
All threads have finished Operating.
Press any key to finish this Program.
程序運行過程中,線程1或線程2向accnt1中借款,一定延時后向accnt2中還款,總額accnt均為0,程序運行結果完全正確。
五、實踐體會
 使用臨界區變量解決臨界區問題實現起來比軟件方法簡單明了,并且可以應用到多進程的情況之中,通過這次實驗我基本了解了臨界區變量的使用方法和作用,其實,解決臨界區問題的方法相當的多,從中選取一種合適的是要很多經驗積累的。

六、參考文獻
1、MSDN

附:源程序代碼
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
#include <fstream.h>
#include <stdio.h>
#include <time.h>
#define INTE_PER_SEC  500
#define MAX_THREAD_NUM  64
#define RIGHT_VERSION TRUE
#define WRONG_VERSION FALSE

CRITICAL_SECTION  my_section;

struct ThreadInfo
{
 int serial;
 double  delay;
};

/*volatile*/  int accnt1 = 0; 
/*volatile*/  int accnt2 = 0;
/*volatile*/  int accnt;

void account( char* file,BOOL version);
void acc_right(void* p);
void acc_wrong(void* p);

////////////////////////////////////////////////////////
// main function
////////////////////////////////////////////////////////

int main( int agrc, char* argv[] )
{
 char ch;

 while ( TRUE )
 {
  // Clear screen
  system( "cls" );

  // display prompt info
  printf("*********************************************\n");
  printf("       1.Start the right version(with the using of CRITICAL_SECTION)\n");
  printf("       2.Start the wrong version(without any algorithm of synchronization)\n");
  printf("       3.Exit to Windows\n");
  printf("*********************************************\n");
  printf("Input your choice(1 、2 or 3): ");

  // if the number inputed is error, retry!
  do
  {
   ch = (char)_getch(); 
  }while ( ch != '1' && ch != '2'&& ch != '3');

  system ( "cls" );
  if ( ch == '1')
   account("ex3.dat",RIGHT_VERSION);
  else if (ch =='2')
   account("ex3.dat",WRONG_VERSION);
  else if ( ch == '3')
   return 0;
  printf("\nPress any key to finish this Program. \n");
  _getch();
 } //end while
} //end main

void account( char* file,BOOL version)
{
 DWORD n_thread = 0;
 DWORD thread_ID;
 DWORD wait_for_all;
// Tread Object Array

 HANDLE h_Thread[MAX_THREAD_NUM];
 ThreadInfo  thread_info[MAX_THREAD_NUM];

 ifstream  inFile;
 inFile.open(file);  //open file
 printf( "Now, We begin to read thread Information to thread_info array \n\n" );

 while ( inFile )
 {
  // read every thread info
  inFile>>thread_info[n_thread].serial;
  inFile>>thread_info[n_thread++].delay;
  inFile.get();
 } //end while

// initialize the data
 srand((unsigned)time(NULL));
 accnt1=0;
 accnt2=0;
// Create all thread
 if (version==RIGHT_VERSION)
 {
  InitializeCriticalSection(&my_section);  //init critical section
  for ( int i = 0; i < (int)(n_thread); i++)
  {
   // Create a thread
   h_Thread[i] = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)(acc_right), &thread_info[i], 0, &thread_ID);
  } //end for
 } else
 {
  for ( int i = 0; i < (int)(n_thread); i++)
  {
   // Create a thread
   h_Thread[i] = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)(acc_wrong), &thread_info[i], 0, &thread_ID);
  } //end for
 }
// Create thread
// waiting all thread will been finished
 wait_for_all = WaitForMultipleObjects(n_thread,h_Thread,TRUE, -1);
 printf("All threads have finished Operating.\n");
}// end account

void acc_right(void* p)
{
 DWORD m_delay;
 int m_serial;
 int tmp1 , tmp2, rand_num;
 int counter = 0;
//get info from para
 m_serial = ((ThreadInfo*) (p)) -> serial;
 m_delay  = (DWORD) (((ThreadInfo*)(p)) -> delay*INTE_PER_SEC);
 do
 {
  EnterCriticalSection(&my_section);
//begin critical_section
  printf("I am thread  %d , I am doing  %05dth step\n",m_serial,counter);
  tmp1 = accnt1;
  tmp2 = accnt2;
  rand_num = rand();
  accnt1 = tmp1 - rand_num;
  Sleep(m_delay);
  accnt2 = tmp2 + rand_num;
  accnt = accnt1 + accnt2;
//critical_section  end
  LeaveCriticalSection(&my_section);
  counter++;
  printf("Now the random number is %d ; and accnt1+accnt2 =  %05d\n\n",rand_num,accnt);
 } while (counter<5); 
 printf("At last of thread %d accnt1+accnt2 =  %05d\n",m_serial,accnt);
} //end acc_right

void acc_wrong(void* p)
{
 DWORD m_delay;
 int m_serial;
 int tmp1 , tmp2, rand_num;
 int counter = 0;
//get info from para
 m_serial = ((ThreadInfo*) (p)) -> serial;
 m_delay  = (DWORD) (((ThreadInfo*)(p)) -> delay*INTE_PER_SEC);
 do
 {
//begin critical_section
  printf("I am thread  %d , I am doing  %05dth step\n",m_serial,counter);
  tmp1 = accnt1;
  tmp2 = accnt2;
  rand_num = rand();
  accnt1 = tmp1 - rand_num;
  Sleep(m_delay);
  accnt2 = tmp2 + rand_num;
  accnt = accnt1 + accnt2;
//critical_section  end
  counter++;
  printf("Now the random number is %d ; and accnt1+accnt2 =  %05d\n\n",rand_num,accnt);
 } while (counter<5); 
 printf("At last of thread %d accnt1+accnt2 =  %05d\n",m_serial,accnt);
} //end acc_wrong

任務四  同步對象解決有限緩沖區問題
一、基本信息
實踐題目:同步對象解決有限緩沖區問題
二、實踐內容簡要描述

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日本一道本| 国产欧美精品一区aⅴ影院| 婷婷国产在线综合| 9191久久久久久久久久久| 日韩专区一卡二卡| 欧美一区二区三区四区视频| 蜜桃视频在线一区| 精品国产a毛片| 国产.欧美.日韩| 亚洲欧洲色图综合| 在线观看网站黄不卡| 图片区小说区国产精品视频| 日韩一区二区三区精品视频| 国产乱子伦一区二区三区国色天香| 久久久国产一区二区三区四区小说| 国产不卡在线播放| 亚洲精品乱码久久久久久黑人| 91激情五月电影| 日本视频一区二区| 国产偷国产偷亚洲高清人白洁| av在线不卡网| 亚洲国产精品综合小说图片区| 91精品国产一区二区三区香蕉| 激情文学综合插| 国产精品欧美久久久久一区二区| 欧洲精品在线观看| 久久精品国产网站| 国产精品激情偷乱一区二区∴| 欧美在线不卡一区| 久88久久88久久久| 自拍偷拍亚洲激情| 777a∨成人精品桃花网| 国产精品99久久久久久似苏梦涵| 亚洲欧美日韩中文字幕一区二区三区| 欧美日韩不卡一区| 国产夫妻精品视频| 亚洲成人av电影| 久久午夜色播影院免费高清| 一本色道**综合亚洲精品蜜桃冫| 日韩 欧美一区二区三区| 久久久久99精品国产片| 欧洲国产伦久久久久久久| 久久精品国产秦先生| 亚洲色图色小说| 日韩一级视频免费观看在线| 99免费精品在线观看| 奇米影视在线99精品| 国产精品的网站| 欧美videos中文字幕| 色国产综合视频| 国产精品一区一区| 午夜私人影院久久久久| 中文在线一区二区| 91精品国产免费| 色综合天天天天做夜夜夜夜做| 日本aⅴ精品一区二区三区 | 国产日韩欧美精品在线| 在线免费观看日韩欧美| 国产精品一区二区久激情瑜伽| 亚洲一区二区高清| 国产精品狼人久久影院观看方式| 91精品国产福利在线观看| 91伊人久久大香线蕉| 久久国产精品99久久久久久老狼| 亚洲精品免费在线| 国产女同互慰高潮91漫画| 欧美一区二区三区啪啪| 91麻豆免费观看| 成人丝袜18视频在线观看| 玖玖九九国产精品| 日韩专区一卡二卡| 一区二区日韩av| 中文字幕一区二区三区av| 久久九九全国免费| 日韩女优电影在线观看| 欧美日韩一区二区三区四区| 99久久精品情趣| 国产成人精品一区二| 老司机午夜精品| 日本午夜精品一区二区三区电影| 亚洲综合色噜噜狠狠| 国产精品久久久久久久久果冻传媒| 精品99久久久久久| 91精品欧美久久久久久动漫| 色综合久久88色综合天天6| 美女在线一区二区| 一个色在线综合| 中文字幕的久久| 精品理论电影在线| 欧美日本在线观看| 色成年激情久久综合| 粉嫩av一区二区三区| 国产精品综合在线视频| 免费一级欧美片在线观看| 一区二区三区在线高清| 国产精品国产精品国产专区不蜜| wwwwxxxxx欧美| 精品国产一区二区在线观看| 欧美久久久久久久久| 欧洲国内综合视频| 色视频欧美一区二区三区| av综合在线播放| 成人性生交大片免费看在线播放| 精品一区二区国语对白| 丝袜诱惑亚洲看片| 一二三四区精品视频| 亚洲欧美自拍偷拍| 中文av一区特黄| 日韩欧美在线1卡| 欧美日韩1区2区| 欧美日韩免费一区二区三区| 色综合久久综合网97色综合 | 国产又粗又猛又爽又黄91精品| 日韩高清不卡一区| 亚洲3atv精品一区二区三区| 一级女性全黄久久生活片免费| 国产精品乱人伦中文| 日韩毛片精品高清免费| 亚洲天堂2014| 国产精品久久久一本精品| 久久日一线二线三线suv| 国产欧美一区二区三区网站| 国产午夜精品福利| 欧美国产丝袜视频| 国产日韩欧美在线一区| 国产精品沙发午睡系列990531| 国产亚洲1区2区3区| 国产日产亚洲精品系列| 国产精品免费看片| 中文字幕一区二区三区不卡| 日韩久久一区二区| 亚洲欧美偷拍另类a∨色屁股| 亚洲老司机在线| 亚洲免费观看视频| 国产精品午夜在线| 国产亚洲综合av| 国产精品视频一区二区三区不卡| 国产欧美日韩在线视频| 国产欧美日韩在线| 亚洲欧美在线视频观看| 亚洲精品五月天| 亚洲在线视频网站| 亚洲一区二区在线免费看| 亚洲午夜一区二区三区| 日韩**一区毛片| 日本中文在线一区| 蜜桃视频第一区免费观看| 激情综合网激情| 成人性生交大片免费| www.成人在线| 在线区一区二视频| 欧美亚洲图片小说| 欧美一区二区三区播放老司机| 精品三级av在线| 日本一区二区综合亚洲| 亚洲永久免费av| 日本aⅴ亚洲精品中文乱码| 国产呦萝稀缺另类资源| 国产一区欧美二区| 欧美在线视频日韩| 欧美一区二区视频在线观看| 久久综合九色综合欧美亚洲| 国产精品午夜免费| 天天综合天天综合色| 韩国理伦片一区二区三区在线播放| 国产91丝袜在线观看| 99re这里只有精品6| 欧美在线啊v一区| 精品成人a区在线观看| 中文字幕亚洲视频| 亚洲一区欧美一区| 一区二区三区在线视频播放| 免费在线看一区| 成人aa视频在线观看| 91色porny蝌蚪| 欧美精品在线观看一区二区| 欧美精品一区二区精品网| 国产精品国产自产拍高清av| 亚洲无人区一区| 国产乱码精品1区2区3区| 色婷婷久久综合| 日韩欧美激情在线| 国产精品灌醉下药二区| 亚洲一区二区三区三| 黑人巨大精品欧美一区| 色综合色综合色综合| 精品日本一线二线三线不卡| 国产精品福利一区二区三区| 日韩黄色小视频| 不卡一区二区三区四区| 91精品国产综合久久香蕉的特点| 久久香蕉国产线看观看99| 亚洲一区二区精品久久av| 国产一区二区三区精品欧美日韩一区二区三区 | 伊人性伊人情综合网| 国产在线精品一区二区夜色| 日本不卡在线视频| 色一区在线观看| 久久无码av三级| 午夜久久久久久久久|