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

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

?? 設計報告.txt

?? 主要功能: 1、 包括顧客信息、貨品信息、定單信息的管理。 2、 按月統計銷售業績。 3、 報表設計。 4、 系統維護。
?? TXT
?? 第 1 頁 / 共 4 頁
字號:
任務一  實現批處理
一、基本信息
實踐題目:實現批處理
二、實踐內容簡要描述
實踐目標:
(1)了解Windows2000操作系統的基本結構
(2)學會在Win32環境下,通過函數 BOOL CreateProcess(LPCTSTR lpApplicationName,LPTSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles,  DWORD dwCreationFlags, LPVOID lpEnvironment,  LPCTSTR lpCurrentDirectory, LPSTARTUPINFO lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)創建進程。
(3)學會用CreateFile ReadFile讀文件,用FormatMessage處理出錯信息。
實踐內容:
從batch文件中正確讀入應用程序命令行及其參數,并依次為其創建相應進程。
三、實踐報告主要內容
設計思路:
(1)先打開文件 :使用CreateFile打開一個文件,獲得HANDLE hFile
(2)然后讀取文件 :用ReadFile通過已經獲得HANDLE hFile的讀取文件,并賦給inBuffer
(3)格式或處理讀取信息并創建進程 :將inBuffer 中的信息格式化提取并用CreateProcess創建進程
主要代碼結構:
/* 1.create the file and get the handle*/
 HANDLE hFile=CreateFile("batch",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
 
/* 2.judge if the file is open and get the error imformation */
 if(hFile==INVALID_HANDLE_VALUE)
 {
  LPVOID lpMsgBuf;
  FormatMessage( 
     FORMAT_MESSAGE_ALLOCATE_BUFFER | 
  FORMAT_MESSAGE_FROM_SYSTEM | 
     FORMAT_MESSAGE_IGNORE_INSERTS,
  NULL,
     GetLastError(),
     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  (LPTSTR) &lpMsgBuf,
  0,
  NULL 
  );
  fprintf(stdout,(char*)(lpMsgBuf));
  ExitProcess(1);
 }
/* 3.read file and detect the error infomation */
 BOOL bResult;
 char inBuffer[1000];     // pointer to buffer that receives data
 DWORD nBytesToRead=900;   // number of bytes to read
 DWORD nBytesRead;
 LPDWORD lpnBytesRead=&nBytesRead;  // pointer to number of bytes read
 bResult =ReadFile(
  hFile,    // handle of file to read
  inBuffer,   // pointer to buffer that receives data
  nBytesToRead,  // number of bytes to read
  lpnBytesRead,  // pointer to number of bytes read
  NULL    // pointer to structure for data
);

/* 4.get the command from the buffer */
 count=0;
 pos=0;
 for (i=0;i<(int)nBytesRead;i++)
 {
  if(inBuffer[i]!=10 && inBuffer[i]!=13)
  {
   cmdLine[count][pos]=inBuffer[i];
   pos++;
   continue;
  }
  if(inBuffer[i]==10)
  {
   cmdLine[count][pos]=0;
   pos=0;
   count++;
  }
 }
/* 5.copy the command from command line parameters */
 for ( i = 0; i < count ; i++) {
  if(!CreateProcess( 
       lpApplicationName, /* File name of executable */
       cmdLine[i],   /* Command line */
       processSA,   /* Process inherited security */
       threadSA,   /* Thread inherited security */
       shareRights,  /* Right propagation */
       creationMask,  /* Various creation flags */
       environment,  /* Environment variabkesr */
       curDir,    /* Child's current directory */
       &startInfo,
       &processInfo
       )
    ) {
    fprintf(stderr,"CreatProcess failed on error %d\n",GetLastError());
    ExitProcess(1);
   };
  fprintf(stdout,"The Child Process's PID: %d.\n", processInfo.dwProcessId);
  fprintf(stdout,"The Parent Process finish.\n");
  Sleep(500);
  CloseHandle(processInfo.hProcess);
  CloseHandle(processInfo.hThread);
 };
四、實踐結果
基本數據:
 
源程序代碼行數 完成實踐投入的總時間 編程調試時間 源程序文件    
116 2.5小時 0.5小時 ex1.cpp  
測試數據設計:
“batch”文件內容如下:
  c:\windows\notepad.exe  
   c:\windows\system32\calc.exe    
  c:\windows\system32\mspaint.exe 
測試結果分析:
程序能夠依次打開notepad,calc和mspaint,并顯示
The Child Process's PID: 1712.
The Parent Process finish.
The Child Process's PID: 3276.
The Parent Process finish.
The Child Process's PID: 3876.
The Parent Process finish.
五、實踐體會
第1個任務比較簡單,我參考樣例程序并查閱有關資料,在這個實驗上沒有遇到比較棘手的問題,通過任務1,我了解了創建進程的方法,對創建進程CreateProcess()函數中的各個參數有了一個初步的認識。

任務二  軟件方法解決臨界區問題
一、基本信息
實踐題目:軟件方法解決臨界區問題-兄弟問題
二、實踐內容簡要描述
實踐目標:
用軟件方法(Peterson算法或Dekker算法等)解決臨界區問題-兄弟問題。
實踐內容:
設置競爭條件:
定義兩個全局變量:accnt1和accnt2,初值都為零;
創建兩個線程acc1和acc2;
(1)獲得一個隨機數
(2)從accnt1減去這個隨機數;
(3)將這個隨機數加到accnt2中;
(4)正確的話,accnt1+accnt2=0。
設置條件使其不正確。
用軟件方法實現協作線程,以解決以上臨界區問題,即兄弟問題。
三、實踐報告主要內容
設計思路:
選擇算法:
Dekker算法——該算法主要用于解決兩個線程的臨界區問題,是典型的軟件方法解決臨界區問題的算法。
設計思路:
線程Pi結構如下:
do{
 flag[i]=true;
 while(flag[j]){
  if(turn==j) {
   flag[i] = false;
   while(turn==j);
   flag[i]=true;
  }
 }
  critical section
turn=j;
flag[i]=false;
remainder section
}while(1);
每個在進入臨界區前用entry section實行判斷等待,離開臨界區后發出信號通知別的線程可以進入臨界區,這樣可以防止兩個線程同時訪問臨界區。
在程序中i表示自身線程序號,再用兩個線程序號之和減去i即可表示另外那個線程的序號。
主要數據結構:
struct ThreadInfo
{
 int serial;
 double delay;
};//存放線程的ID及其執行延時(模擬兄弟在外創業的時間)
/*volatile*/  int accnt1 = 0;  //借款帳戶中金額
/*volatile*/  int accnt2 = 0;  //還款帳戶中金額
/*volatile*/  int accnt;  //借款帳戶與還款帳戶金額總和,應保持為0
/* variables for Dekker's arithmetic */
BOOL flag[2]={false,false};// flag[i] = true表示線程Pi 準備進入臨界區
int turn;   // turn = i表示線程Pi允許在臨界區執行
int i = m_serial;  // 自身線程序號
int j = 1 - m_serial;   // 另外那個線程序號
主要代碼結構:
do{
entry section
critical section
exit section
remainder section
}while(1);
主要代碼分析:
1.entry section用于在進入臨界區時的等待
  /* entry section begin */
  flag[m_serial]=true;
  turn=1-m_serial;
  while (flag[1-m_serial] && turn==1-m_serial);
  /* entry section end   */
2.exit section用于離開臨界區后的發送信號的工作,通知另外的線程可以進入臨界區
  /* exit section begin */
  flag[m_serial]=false;
  /* exit section end   */
四、實踐結果
基本數據:
 
源程序代碼行數 完成實踐投入的總時間 資料查閱時間 編程調試時間 源程序文件    
196 0.5小時 0.3小時 0.2小時 ex2.cpp  

測試數據設計:
“ex2.dat”文件內容如下:
 0  1
0  1
測試結果分析:
運行結果圖如下所示:
Now, We begin to read thread Information to thread_info array
I am thread  0 , I am doing  00000th step
Now the random number is 20571 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00000th step
Now the random number is 17781 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00001th step
Now the random number is 22438 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00001th step
Now the random number is 17547 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00002th step
Now the random number is 27554 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00002th step
Now the random number is 25718 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00003th step
Now the random number is 18778 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00003th step
Now the random number is 8063 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00004th step
Now the random number is 30162 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00004th step
Now the random number is 29448 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00005th step
Now the random number is 7046 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00005th step
Now the random number is 8096 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00006th step
Now the random number is 16582 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00006th step
Now the random number is 8806 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00007th step
Now the random number is 1534 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00007th step
Now the random number is 31418 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00008th step
Now the random number is 21293 ; and accnt1+accnt2 =  00000
I am thread  1 , I am doing  00008th step
Now the random number is 9811 ; and accnt1+accnt2 =  00000
I am thread  0 , I am doing  00009th step
Now the random number is 22034 ; and accnt1+accnt2 =  00000
At last of thread 0 accnt1+accnt2 =  00000
I am thread  1 , I am doing  00009th step
Now the random number is 20276 ; and accnt1+accnt2 =  00000
At last of thread 1 accnt1+accnt2 =  00000
All threads have finished Operating.
Press any key to finish this Program.
五、實踐體會
 解決線程同步問題的關鍵是避免兩個以上線程同時訪問臨界區數據,在實驗中,由于entry section 和exit section所放位置不對導致了很多的錯誤,將entry section放在讀取帳戶數據后會出現讀取數據出錯導致帳戶總額不對,因為可能讀取到的是臟數據,將讀取帳戶數據和對其進行修改的代碼放在entry section和exit section之間,即可確保同時只能有一個線程對其訪問和操作,從而正確解決了問題。
 
六、參考文獻
1、MSDN
2、《操作系統概念(第六版 影印版)》,Abraham Silberschatz、Peter Baer Galvin、Greg Gagne,
高等教育出版社

附:源程序代碼
#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
struct ThreadInfo
{
 int serial;
 double  delay;
};

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

BOOL flag[2]={false,false};
int turn;

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 PETERSON algorithm)\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,2or3): ");

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

  system ( "cls" );
  if ( ch == '1')
   account("ex2.dat",RIGHT_VERSION);
  else if (ch =='2')
   account("ex2.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)
 {

  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

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕高清不卡| 欧美成va人片在线观看| 中文字幕欧美日韩一区| 成人午夜激情视频| 中文字幕一区二区三区乱码在线| 99re这里都是精品| 亚洲亚洲精品在线观看| 91精品国产色综合久久| 国产在线视频一区二区三区| 久久精品人人爽人人爽| 成人av在线看| 亚洲第一主播视频| 欧美精品一区二区三区蜜桃视频 | 日韩三区在线观看| 国产一区啦啦啦在线观看| 中文字幕欧美三区| 欧美视频日韩视频在线观看| 天堂在线亚洲视频| 久久久久国产精品厨房| 色欧美片视频在线观看| 免播放器亚洲一区| 国产欧美日韩三区| 欧美日本精品一区二区三区| 国产美女娇喘av呻吟久久| 亚洲欧洲日产国产综合网| 欧美三级视频在线观看| 国产在线播放一区二区三区| 亚洲免费观看高清完整版在线观看 | 爽爽淫人综合网网站| 2020国产精品| 在线观看日韩一区| 国产真实精品久久二三区| 亚洲精品视频免费观看| 精品国内片67194| 色婷婷亚洲精品| 国产精品一区二区果冻传媒| 亚洲图片欧美一区| 国产精品乱子久久久久| 在线播放欧美女士性生活| 国产91精品一区二区麻豆亚洲| 亚洲一区二区三区免费视频| 国产日本欧美一区二区| 正在播放亚洲一区| 91成人在线精品| 成人av电影在线观看| 毛片不卡一区二区| 一区二区免费看| 日本一区二区视频在线| 欧美成人a视频| 欧美精品粉嫩高潮一区二区| 91麻豆.com| 懂色中文一区二区在线播放| 强制捆绑调教一区二区| 亚洲综合在线免费观看| 国产精品久久777777| 久久亚洲精精品中文字幕早川悠里| 欧美午夜寂寞影院| 91捆绑美女网站| 成人免费看片app下载| 国产一区在线观看视频| 久色婷婷小香蕉久久| 午夜激情一区二区| 亚洲大片在线观看| 亚洲午夜久久久久久久久电影网 | 性欧美大战久久久久久久久| 中文字幕成人在线观看| 精品三级在线观看| 日韩一区国产二区欧美三区| 欧美色网站导航| 欧美性三三影院| 欧美三级在线看| 欧美中文字幕亚洲一区二区va在线| 99久久久精品| 99视频一区二区三区| 成人av电影在线观看| 不卡区在线中文字幕| 成人久久久精品乱码一区二区三区| 国内精品国产成人国产三级粉色 | 不卡欧美aaaaa| 不卡欧美aaaaa| 91丨国产丨九色丨pron| 色综合久久久久综合体| 91成人看片片| 666欧美在线视频| 欧美成人一级视频| 久久精品视频免费观看| 欧美激情综合在线| 日韩理论在线观看| 亚洲精品视频在线看| 亚洲已满18点击进入久久| 亚洲成在人线免费| 秋霞电影一区二区| 国模一区二区三区白浆| 成人午夜免费av| 在线观看三级视频欧美| 欧美美女网站色| 亚洲精品在线一区二区| 国产欧美日韩亚州综合 | 欧美日韩亚洲综合一区二区三区| 4438成人网| 久久九九国产精品| 亚洲日本乱码在线观看| 亚洲一区二区三区不卡国产欧美| 日韩黄色小视频| 国产麻豆视频一区| 色综合一区二区| 欧美二区三区的天堂| 亚洲精品一区二区三区在线观看 | 天堂一区二区在线| 国产精品一区二区在线观看不卡 | 久久不见久久见免费视频1| 国产精品综合网| 欧美制服丝袜第一页| 精品国产制服丝袜高跟| 中文字幕一区二区5566日韩| 亚洲成av人综合在线观看| 国产美女精品人人做人人爽| 色婷婷av一区二区三区之一色屋| 日韩一区二区三区在线视频| 国产精品久久久久久亚洲毛片| 亚洲成人免费在线观看| 国产精品1区2区| 欧美色网站导航| 国产精品无遮挡| 青青草国产精品97视觉盛宴| 国产91精品一区二区| 91.com在线观看| 亚洲三级久久久| 国产一区二区免费视频| 欧美视频在线一区| 国产女人aaa级久久久级| 亚洲第一av色| 91在线视频在线| 久久久亚洲精品一区二区三区 | 在线观看国产日韩| 久久久久国产精品免费免费搜索| 亚洲午夜久久久久久久久久久| 岛国av在线一区| 日韩一级欧美一级| 亚洲国产美女搞黄色| 成人激情开心网| 久久久久国产精品麻豆ai换脸| 日韩国产高清影视| 欧美亚洲高清一区| 亚洲欧洲性图库| 高清不卡在线观看| 精品国产免费人成电影在线观看四季| 亚洲尤物视频在线| 91激情在线视频| 亚洲日本va午夜在线电影| 国产精品一区不卡| 精品国产乱码久久久久久老虎| 五月婷婷久久综合| 欧美日韩在线播放一区| 亚洲一区二区三区自拍| 一本一本久久a久久精品综合麻豆| 久久亚洲综合色一区二区三区| 老司机精品视频在线| 91精品欧美久久久久久动漫 | 蜜臀久久99精品久久久久久9 | 日韩一区二区三| 麻豆成人av在线| 欧美成va人片在线观看| 精品一区二区三区蜜桃| 日韩欧美国产麻豆| 激情五月播播久久久精品| 日韩精品一区二区三区中文不卡| 日本伊人色综合网| 欧美成人精品福利| 国产麻豆成人精品| 国产亚洲一区二区三区在线观看| 国产一区在线观看视频| 久久理论电影网| 成人免费va视频| 亚洲日本va午夜在线影院| 欧美少妇一区二区| 日本中文字幕一区二区有限公司| 欧美一区二区三区成人| 欧美96一区二区免费视频| 精品国产伦一区二区三区观看方式 | 精品久久久久久久久久久院品网| 久久97超碰国产精品超碰| 亚洲精品一区二区三区四区高清| 国产精品99久久不卡二区| 国产精品激情偷乱一区二区∴| 91在线观看免费视频| 亚洲午夜激情网页| 日韩亚洲欧美中文三级| 久久精品国产精品亚洲综合| 精品国产乱码久久久久久浪潮| 国内精品第一页| 国产精品久线在线观看| 欧美日韩激情一区二区三区| 久草这里只有精品视频| 国产精品久久久久久久久久久免费看 | 国产欧美一区二区精品性色超碰| 成人黄色小视频| 亚洲1区2区3区4区| 久久精品人人做人人综合| 色综合久久综合网|