예제 #1
0
bool RDOPROCSeize::onCheckCondition(const LPRDORuntime& pRuntime)
{
	if (m_transacts.empty())
		return false;

	const std::size_t Size_Seizes = forRes.size();
	for (std::size_t i = 0; i < Size_Seizes; i++)
	{
		// если свободен
		if (forRes[i].rss->getParam(forRes[i].Id_param) == forRes[i].enum_free)
		{
			const std::size_t idBlocksTransact = m_transacts.front()->getTraceID();
			const std::size_t idResourcesTransact = forRes[i].rss->transacts.front()->getTraceID();
			if (idBlocksTransact != idResourcesTransact)
				return false;

			RDOTrace* tracer = pRuntime->getTracer();
			forRes[i].rss->setParam(forRes[i].Id_param, forRes[i].enum_buzy);
			TRACE3("%7.1f SEIZES-%d, resId = %d\n", pRuntime->getCurrentTime(), index, forRes[i].rss->getTraceID());
			if (!tracer->isNull())
				tracer->getOStream() << forRes[i].rss->traceResourceState('\0', pRuntime) << tracer->getEOL();

			m_transacts.front()->setRes(forRes[i].rss);
			return true;
		}
	}
	return false;
}
예제 #2
0
bool RDOPROCRelease::onCheckCondition(const LPRDORuntime& pRuntime)
{
	if (!m_transacts.empty())
	{
		int Size_Seizes = forRes.size();
		for(int i=0;i<Size_Seizes; i++)
		{
			if(forRes[i].rss == m_transacts.front()->getRes())
			{
				// Занят
				if (forRes[i].rss->getParam(forRes[i].Id_param) == forRes[i].enum_buzy)
				{
					RDOTrace* tracer = pRuntime->getTracer();
					TRACE3("%7.1f RELEASES-%d, resId = %d\n", pRuntime->getCurrentTime(), index, forRes[i].rss->getTraceID());
					forRes[i].rss->setParam(forRes[i].Id_param, forRes[i].enum_free);
					if (!tracer->isNull())
					{
						tracer->getOStream() << forRes[i].rss->traceResourceState('\0', pRuntime) << tracer->getEOL();
					}				
					return true;
				}		
				// Не Занят и не свободен
				if (forRes[i].rss->getParam(forRes[i].Id_param) != forRes[i].enum_free)
				{
					//Удаляем транзакт
					RDOTrace* tracer = pRuntime->getTracer();
					TRACE3("%7.1f RELEASES_Bad-%d, resId = %d\n", pRuntime->getCurrentTime(), index, forRes[i].rss->getTraceID());
					LPRDOPROCTransact transact = m_transacts.front();
					ASSERT(transact);
					transact->setState(RDOResource::CS_Erase);
					if (!tracer->isNull())
					{
						tracer->getOStream() << transact->traceResourceState('\0', pRuntime) << tracer->getEOL();
					}
					m_transacts.remove(transact);
					forRes[i].rss->transacts.remove(transact);
					pRuntime->onEraseRes(transact->getTraceID(), NULL);
					return false;
				}
			}
		}
	}
	return false;
}