- 227 名前:デフォルトの名無しさん mailto:sage [2006/10/17(火) 05:34:19 ]
- >>226
初心者なので、せっかくヒントもいただいたので、 セマフォも勉強したいと思いまして。 現状ですが悪戦苦闘中でして、下記のコードになりました。 void thread_A(){ while(1){ WaitForSingleObject(hSemaphore,INFINITE); printf("AのWaitForSingleObject1を通過\n"); WaitForSingleObject(hSemaphore,INFINITE); printf("AのWaitForSingleObject2を通過\n"); for(int i=0;i<5;i++){ printf("Aの処理中なのでB,C割り込んじゃダメ\n"); //Sleep(1000); } ReleaseSemaphore(hSemaphore,2,NULL); } } void thread_B(){ while(1){ //1回待つ WaitForSingleObject(hSemaphore,INFINITE); printf("BのWaitForSingleObjectを通過\n"); //セマフォ1つ開放 ReleaseSemaphore(hSemaphore,1,NULL); printf("Bのセマフォ1つ開放しました\n"); //Sleep(1000); } } //Cも同様
|

|