#define BUFFER_SIZE 10
Typedef struct{
......
}item;
item buffer[BUFFER_SIZE];
int in=0;
int out=0;
.solution is correct but can only use BUFFER_SIZE-1 elements هذا شرح
item nextProduced;
while(1){
while(((in+1)%BUFFER_SIZE)==out)
;/*do nothing*/
bufffer[in]=nextproduced;
in=(in+1)%BUFFER_SIZE;
}
item nextconsumed;
while(1){
while(in==out)
;/*do nothing*/
nextConsumed=buffer[out];
out=(out+1)%BUFFER_SIZE;
}اللي ابغاه برنامج على الكود اللي فوق
مصنع سيارات ينتج حسب المخزن اذا امتلاء يوقف الانتاج
المستهلك ياخذ سيارة يبدا الانتاج