DWORD WINAPI LocalThread(LPVOID parms) { try { for(int i=0;i<1000;i++) { printf("put %d\n",i); q.Put(i); Sleep(10); } } catch(const char * c) { printf("EXCEPTION in THREAD: %s, err=%d\n",c,GetLastError()); } return 0; }
void sim() { int j = 0; int tickskip = 0, proctime = 0, taskskip = 0; int tick; int critT, critP; TQueue queue; printf("??????? ??????????? ???????? ?????\n"); critT = input(DIAP); printf("??????? ??????????? ???????? ??????????\n"); critP = input(DIAP); printf("??????? ?????????? ??????\n"); tick = input(9000); if (tick < 20) { for (int i = 0; i < tick; i++) { if (TaskRand(critT)) { if (!queue.IsFull()) { queue.Put(1); printf("????????? ??????\n"); } else { taskskip++; printf("?????? ?????????\n"); } } if (proctime != 0) { printf("????????? ???????????? ??????\n"); if (ProcRand(critP)) { proctime = 0; printf("?????? ??????????\n"); } else { proctime++; printf("?????? ??????????????\n"); } } else if (!queue.IsEmpty()) { printf("????????? ?????? ??????\n"); queue.Push(); if (ProcRand(critP)) { printf("?????? ??????????\n"); } else { proctime++; printf("?????? ??????????????\n"); } } else { tickskip++; printf("????????? ???????????\n"); } } while (!queue.IsEmpty()) { queue.Push(); j++; } } else { for (int i = 0; i < tick; i++) { if (TaskRand(critT)) { if (!queue.IsFull()) { queue.Put(1); } else { taskskip++; } } if (proctime != 0) { if (ProcRand(critP)) { proctime = 0; } else { proctime++; } } else if (!queue.IsEmpty()) { queue.Push(); if (ProcRand(critP)) { } else { proctime++; } } else { tickskip++; } } while (!queue.IsEmpty()) { queue.Push(); j++; } } printf("????????? ? ???????: %d\n", j); printf("????? ?????????: %d\n ????? ???????: %d\n", taskskip, tickskip); }