| 1713 | |
| 1714 | |
| 1715 | long long cComponentManager::tickLoopA(long long maxtick, int threadId, sThreadData *_data) |
| 1716 | { |
| 1717 | long nRun; int _abort = 0; int doYield=0; |
| 1718 | long long tickNr = -1; |
| 1719 | |
| 1720 | SMILE_MSG(3,"starting processing loop of thread %i",threadId); |
| 1721 | |
| 1722 | do { |
| 1723 | smileMutexLock(syncCondMtx); |
| 1724 | // if runFlag == 0 here... |
| 1725 | runFlag[threadId] = 0; |
| 1726 | tickNr++; //fprintf(stderr, "tick %i eol %i eoi %i\n",tickNr,endOfLoop,EOI); fflush(stderr); |
| 1727 | SMILE_DBG(3,"<------- TICK # %i (thread %i) ---------->",tickNr,threadId); |
| 1728 | smileMutexUnlock(syncCondMtx); |
| 1729 | long tickResultCounts[NUM_TICK_RESULTS]; |
| 1730 | tick(threadId, tickNr, -1, tickResultCounts); |
| 1731 | nRun = tickResultCounts[TICK_SUCCESS]; |
| 1732 | long nWaiting = tickResultCounts[TICK_EXT_SOURCE_NOT_AVAIL] + tickResultCounts[TICK_EXT_DEST_NO_SPACE]; |
| 1733 | SMILE_DBG(3,"nRun = %i (thread %i)",nRun,threadId); |
| 1734 | |
| 1735 | smileMutexLock(abortMtx); |
| 1736 | if (abortRequest) { |
| 1737 | _abort = 1; |
| 1738 | } |
| 1739 | smileMutexUnlock(abortMtx); |
| 1740 | |
| 1741 | if (!_abort) { |
| 1742 | |
| 1743 | smileMutexLock(syncCondMtx); |
| 1744 | // fprintf(stderr,"mutlock...%i\n",threadId); |
| 1745 | if (nRun==0) { |
| 1746 | if (runFlag[threadId] == 1) { |
| 1747 | runFlag[threadId] = 0; |
| 1748 | nRun = 1; |
| 1749 | } else { |
| 1750 | if (!probeFlag) { |
| 1751 | nWaiting++; |
| 1752 | if (nWaiting < nActive) { |
| 1753 | //SMILE_MSG(3, "thread %i sleeping (tick %i) (nAct %i, nWait %i)", threadId, tickNr, nActive, nWaiting); |
| 1754 | smileCondWaitWMtx(syncCond,syncCondMtx); // sleep until another thread or the controller thread wakes us |
| 1755 | //nRun = 1; // runStatus is set by the controller thread, it is 1 by default (=continue) |
| 1756 | } else { |
| 1757 | smileCondSignal(controlCond); // wake up controller thread... |
| 1758 | //SMILE_MSG(3, "thread %i sleeping and signalled controller (tick %i) (nAct %i, nWait %i)", threadId, tickNr, nActive, nWaiting); |
| 1759 | smileCondWaitWMtx(syncCond,syncCondMtx); // and sleep until the controller thread OR ANOTHER THREAD! wakes us |
| 1760 | //nRun = 1; // runStatus is set by the controller thread, it is 1 by default (=continue) |
| 1761 | } |
| 1762 | if (!probeFlag && nWaiting > 0) |
| 1763 | nWaiting--; |
| 1764 | } else { |
| 1765 | nProbe++; |
| 1766 | //nWaiting++; |
| 1767 | if (nProbe == nActive) { |
| 1768 | smileCondSignal(controlCond); // wake up controller thread if we are the last in the probe... |
| 1769 | //SMILE_MSG(3, "PROBE: thread %i signalled controller (tick %i), nprobe = %i, nA %i, nW %i", threadId, tickNr, nProbe, nActive, nWaiting); |
| 1770 | } |
| 1771 | //SMILE_MSG(3, "PROBE: thread %i sleeping (tick %i), nprobe = %i", threadId, tickNr, nProbe); |
| 1772 | smileCondWaitWMtx(syncCond,syncCondMtx); // sleep until the controller thread OR ANOTHER THREAD! wakes us |
no test coverage detected