added mutex IF timeout name

This commit is contained in:
Robin Müller 2020-06-04 20:20:38 +02:00
parent 56340bb8b6
commit 869700e6f5
7 changed files with 28 additions and 24 deletions

View File

@ -61,7 +61,7 @@ ReturnValue_t DataPool::freeDataPoolLock() {
}
ReturnValue_t DataPool::lockDataPool() {
ReturnValue_t status = mutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t status = mutex->lockMutex(MutexIF::BLOCKING);
if ( status != RETURN_OK ) {
sif::error << "DataPool::DataPool: lock of mutex failed with error code: " << status << std::endl;
}

View File

@ -147,7 +147,7 @@ void EventManager::printEvent(EventMessage* message) {
#endif
void EventManager::lockMutex() {
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
}
void EventManager::unlockMutex() {

View File

@ -26,7 +26,7 @@ ReturnValue_t HealthTable::registerObject(object_id_t object,
void HealthTable::setHealth(object_id_t object,
HasHealthIF::HealthState newState) {
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
HealthMap::iterator iter = healthMap.find(object);
if (iter != healthMap.end()) {
iter->second = newState;
@ -36,7 +36,7 @@ void HealthTable::setHealth(object_id_t object,
HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) {
HasHealthIF::HealthState state = HasHealthIF::HEALTHY;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
HealthMap::iterator iter = healthMap.find(object);
if (iter != healthMap.end()) {
state = iter->second;
@ -46,7 +46,7 @@ HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) {
}
uint32_t HealthTable::getPrintSize() {
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
uint32_t size = healthMap.size() * 5 + 2;
mutex->unlockMutex();
return size;
@ -54,7 +54,7 @@ uint32_t HealthTable::getPrintSize() {
bool HealthTable::hasHealth(object_id_t object) {
bool exits = false;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
HealthMap::iterator iter = healthMap.find(object);
if (iter != healthMap.end()) {
exits = true;
@ -64,7 +64,7 @@ bool HealthTable::hasHealth(object_id_t object) {
}
void HealthTable::printAll(uint8_t* pointer, uint32_t maxSize) {
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
uint32_t size = 0;
uint16_t count = healthMap.size();
ReturnValue_t result = SerializeAdapter<uint16_t>::serialize(&count,
@ -85,7 +85,7 @@ void HealthTable::printAll(uint8_t* pointer, uint32_t maxSize) {
ReturnValue_t HealthTable::iterate(
std::pair<object_id_t, HasHealthIF::HealthState> *value, bool reset) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
if (reset) {
mapIterator = healthMap.begin();
}

View File

@ -54,7 +54,7 @@ void InternalErrorReporter::lostTm() {
uint32_t InternalErrorReporter::getAndResetQueueHits() {
uint32_t value;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
value = queueHits;
queueHits = 0;
mutex->unlockMutex();
@ -63,21 +63,21 @@ uint32_t InternalErrorReporter::getAndResetQueueHits() {
uint32_t InternalErrorReporter::getQueueHits() {
uint32_t value;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
value = queueHits;
mutex->unlockMutex();
return value;
}
void InternalErrorReporter::incrementQueueHits() {
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
queueHits++;
mutex->unlockMutex();
}
uint32_t InternalErrorReporter::getAndResetTmHits() {
uint32_t value;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
value = tmHits;
tmHits = 0;
mutex->unlockMutex();
@ -86,14 +86,14 @@ uint32_t InternalErrorReporter::getAndResetTmHits() {
uint32_t InternalErrorReporter::getTmHits() {
uint32_t value;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
value = tmHits;
mutex->unlockMutex();
return value;
}
void InternalErrorReporter::incrementTmHits() {
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
tmHits++;
mutex->unlockMutex();
}
@ -104,7 +104,7 @@ void InternalErrorReporter::storeFull() {
uint32_t InternalErrorReporter::getAndResetStoreHits() {
uint32_t value;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
value = storeHits;
storeHits = 0;
mutex->unlockMutex();
@ -113,14 +113,14 @@ uint32_t InternalErrorReporter::getAndResetStoreHits() {
uint32_t InternalErrorReporter::getStoreHits() {
uint32_t value;
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
value = storeHits;
mutex->unlockMutex();
return value;
}
void InternalErrorReporter::incrementStoreHits() {
mutex->lockMutex(MutexIF::NO_TIMEOUT);
mutex->lockMutex(MutexIF::BLOCKING);
storeHits++;
mutex->unlockMutex();
}

View File

@ -154,7 +154,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t result = timeMutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
@ -169,7 +169,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
if (timeMutex == NULL) {
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t result = timeMutex->lockMutex(MutexIF::NO_TIMEOUT);
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}

View File

@ -2,7 +2,8 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/timemanager/Clock.h>
const uint32_t MutexIF::NO_TIMEOUT = 0;
const uint32_t MutexIF::POLLING = 0;
const uint32_t MutexIF::NO_TIMEOUT = 0xffffffff;
uint8_t Mutex::count = 0;
@ -39,7 +40,10 @@ Mutex::~Mutex() {
ReturnValue_t Mutex::lockMutex(uint32_t timeoutMs) {
int status = 0;
if (timeoutMs != MutexIF::NO_TIMEOUT) {
if(timeoutMs == MutexIF::POLLING) {
status = pthread_mutex_trylock(&mutex);
}
else if (timeoutMs != MutexIF::BLOCKING) {
timespec timeOut;
clock_gettime(CLOCK_REALTIME, &timeOut);
uint64_t nseconds = timeOut.tv_sec * 1000000000 + timeOut.tv_nsec;

View File

@ -49,7 +49,7 @@ public:
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::reserveSpace(const uint32_t size, store_address_t* address, bool ignoreFault) {
MutexHelper mutexHelper(mutex,MutexIF::NO_TIMEOUT);
MutexHelper mutexHelper(mutex,MutexIF::BLOCKING);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::reserveSpace(size,address,ignoreFault);
return status;
}
@ -70,7 +70,7 @@ template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
store_address_t packet_id) {
// debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store " << packet_id.pool_index << ". id is " << packet_id.packet_index << std::endl;
MutexHelper mutexHelper(mutex,MutexIF::NO_TIMEOUT);
MutexHelper mutexHelper(mutex,MutexIF::BLOCKING);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(packet_id);
return status;
}
@ -78,7 +78,7 @@ inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(uint8_t* buffer, uint32_t size,
store_address_t* storeId) {
MutexHelper mutexHelper(mutex,MutexIF::NO_TIMEOUT);
MutexHelper mutexHelper(mutex,MutexIF::BLOCKING);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(buffer, size, storeId);
return status;
}