Commit 78fe23d3 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by bliss administrator

Fix dead-lock issues, improve Camera:AcqThread::start/stop API:

* Signature forces the caller to lock the mutex of the condition to wait on
parent fd5acbc4
Pipeline #33462 failed with stages
in 6 minutes and 10 seconds
......@@ -201,8 +201,8 @@ private:
AcqThread(Camera *cam);
void queueFinishedFrame(FrameType frame);
virtual void start();
void stop(bool wait);
virtual void start(AutoMutex& l);
void stop(AutoMutex& l, bool wait);
protected:
virtual void threadFunction();
......
......@@ -1649,8 +1649,10 @@ void GlobalCPUAffinityMgr::recvFinished()
m_state = Ready;
}
}
if (m_state == Ready)
if (m_state == Ready) {
m_cond.broadcast();
return;
}
CPUAffinity recv_all = RecvCPUAffinityList_all(m_curr.recv);
DEB_TRACE() << DEB_VAR2(m_curr.lima, recv_all);
......
......@@ -109,10 +109,13 @@ Camera::AcqThread::AcqThread(Camera *cam)
DEB_CONSTRUCTOR();
}
void Camera::AcqThread::start()
void Camera::AcqThread::start(AutoMutex& l)
{
DEB_MEMBER_FUNCT();
if ((&l.mutex() != &m_cond.mutex()) || !l.locked())
THROW_HW_ERROR(Error) << "Invalid AutoMutex";
m_state = Starting;
Thread::start();
......@@ -122,13 +125,16 @@ void Camera::AcqThread::start()
if (ret != 0)
DEB_ERROR() << "Could not set AcqThread real-time priority!!";
while (m_state != Running)
while (m_state == Starting)
m_cond.wait();
}
void Camera::AcqThread::stop(bool wait)
void Camera::AcqThread::stop(AutoMutex& l, bool wait)
{
DEB_MEMBER_FUNCT();
if ((&l.mutex() != &m_cond.mutex()) || !l.locked())
THROW_HW_ERROR(Error) << "Invalid AutoMutex";
m_state = StopReq;
m_cond.broadcast();
while (wait && (m_state != Stopped) && (m_state != Idle))
......@@ -847,7 +853,7 @@ void Camera::startAcq()
cb_mgr->setStartTimestamp(Timestamp::now());
m_acq_thread = new AcqThread(this);
m_acq_thread->start();
m_acq_thread->start(l);
}
void Camera::stopAcq()
......@@ -860,7 +866,7 @@ void Camera::stopAcq()
if (getEffectiveState() != Running)
return;
m_acq_thread->stop(true);
m_acq_thread->stop(l, true);
if (getEffectiveState() != Idle)
THROW_HW_ERROR(Error) << "Camera not Idle";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment