void ThreadManager::taskExecutor(int id) { // pick a task and pop it from the list // if we have some other tasks pending, wake the next thread to handle it // execute the task // wait for notification TaskExecutor& t = m_taskExecutor[id]; TaskExecutor& tNext = m_taskExecutor[(id + 1) % 4]; while (!t.m_stop) { std::unique_lock<std::mutex> execLock(t.m_lock); t.m_cond.wait(execLock); std::unique_lock<std::mutex> lock(m_tasksLock); if (m_tasks.empty()) continue; std::function<void()> taskFunc = m_tasks.back(); m_tasks.pop_back(); if (!m_tasks.empty()) { // notify another thread as we still have tasks pending tNext.m_cond.notify_one(); } lock.unlock(); taskFunc(); } }
void taskRun(unsigned char *ind, unsigned char *pole) { outp(TASK_ADDR0, ((unsigned int)ind ) & 0xFF); //nejnizsi bajt adresy outp(TASK_ADDR1, ((unsigned int)ind >> 8) & 0xFF); outp(TASK_CMD, 0x01); //dam prikaz pro monitorovani adresy z CPU. Pokud bude CPU adresovat stejnou adresu, ktera je ulozena v SIMI_ADDR, pak provedu prepnuti pameti taskFunc = pole; taskFunc(); }