task main() { checkBTLinkConnected(); cCmdBTPurgeRcvBuffer(); purgeBT(mailbox1); clearSendMessage(); while(true) { clearBuffers(); readAndSend(mailbox1, mailbox11); if(dataReceived[1]==1) { send2=true; PlaySound(soundFastUpwardTones); } clearBuffers(); } }
int PerfGroup::onlineCPU(const uint64_t currTime, const int cpu, const bool enable, Buffer *const buffer) { bool addedEvents = false; if (!gSessionData.mPerf.getLegacySupport()) { int idCount = 0; int coreKeys[ARRAY_LENGTH(mKeys)]; __u64 ids[ARRAY_LENGTH(mKeys)]; for (int i = 0; i < ARRAY_LENGTH(mKeys); ++i) { const int fd = mFds[cpu + i * gSessionData.mCores]; if (fd < 0) { continue; } coreKeys[idCount] = mKeys[i]; if (ioctl(fd, PERF_EVENT_IOC_ID, &ids[idCount]) != 0 && // Workaround for running 32-bit gatord on 64-bit systems, kernel patch in the works ioctl(fd, (PERF_EVENT_IOC_ID & ~IOCSIZE_MASK) | (8 << _IOC_SIZESHIFT), &ids[idCount]) != 0) { logg.logMessage("ioctl failed"); return 0; } ++idCount; addedEvents = true; } buffer->marshalKeys(currTime, idCount, ids, coreKeys); } else { int idCounts[ARRAY_LENGTH(mLeaders)] = { 0 }; int coreKeys[ARRAY_LENGTH(mLeaders)][ARRAY_LENGTH(mKeys)]; for (int i = 0; i < ARRAY_LENGTH(mKeys); ++i) { const int fd = mFds[cpu + i * gSessionData.mCores]; if (fd < 0) { continue; } const int effectiveType = getEffectiveType(mAttrs[i].type, mFlags[i]); if (mAttrs[i].pinned && mLeaders[effectiveType] != i) { if (!readAndSend(currTime, buffer, fd, 1, mKeys + i)) { return 0; } } else { coreKeys[effectiveType][idCounts[effectiveType]] = mKeys[i]; ++idCounts[effectiveType]; addedEvents = true; } } for (int i = 0; i < ARRAY_LENGTH(mLeaders); ++i) { if (idCounts[i] > 0 && !readAndSend(currTime, buffer, mFds[mLeaders[i] * gSessionData.mCores + cpu], idCounts[i], coreKeys[i])) { return 0; } } } if (enable) { for (int i = 0; i < ARRAY_LENGTH(mKeys); ++i) { int offset = i * gSessionData.mCores + cpu; if (mFds[offset] >= 0 && ioctl(mFds[offset], PERF_EVENT_IOC_ENABLE, 0) != 0) { logg.logMessage("ioctl failed"); return 0; } } } if (!addedEvents) { logg.logMessage("no events came online"); } return 1; }