Hoc Tap

Learning
 
HomeHome  FAQFAQ  SearchSearch  RegisterRegister  Log inLog in  
 

SXTT4

View previous topic View next topic Go down 
AuthorMessage
dinhkhoi2002vn




Joined : 07 May 2008
Posts : 15

PostSubject: SXTT4   24/6/2008, 11:45

Minh tranh thu thoi gian len dien dan thay cac ban tham gia soi noi qua tiec la minh khong co nhieu thoi gian de tham gia cung cac ban.
Day la bai toan SXTT4 bang cach dung M1C de dinh nghia so luong nha San Xuat va Tieu thu("MAX"), cac ban co the tham khao va phat trien them.

// SxTt4.cpp : Defines the entry point for the console application.

#include "stdafx.h"

#define MAX 10
…….
…….
int main(){
HANDLE ProducerHandle[MAX];
HANDLE ConsumerHandle[MAX];

DWORD ProducerID[MAX];
DWORD ConsumerID[MAX];
………
………
InitializeCriticalSection(&critSec);

// Tao cac luong nhung khong cho o trang thai ngu bang cach doi cac doi so 4 thanh 0
int I;
for(i=0;i<MAX;i++){
ProducerHandle[i]=CreateThread(0,0,(LPTHREAD_START_ROUTINE)Producer, (void *) 1, 0, &ProducerID[i]);
ConsumerHandle[i]=CreateThread(0,0,(LPTHREAD_START_ROUTINE)Consumer, 0, 0, &ConsumerID[i]);
}
……….
……….
Back to top Go down

SXTT4

View previous topic View next topic Back to top 
Page 1 of 1

Permissions of this forum:You cannot reply to topics in this forum
Hoc Tap :: Môn học HĐH :: Hệ Điều Hành-