fix(sysman): fixes multithread access issue with FDCache

Related-To: NEO-9720

Signed-off-by: Kulkarni, Ashwin Kumar <ashwin.kumar.kulkarni@intel.com>
This commit is contained in:
Kulkarni, Ashwin Kumar
2023-12-07 07:40:17 +00:00
committed by Compute-Runtime-Automation
parent f395bdbdab
commit a064388ba8
6 changed files with 66 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ void FdCacheInterface::eraseLeastUsedEntryFromCache() {
}
int FdCacheInterface::getFd(std::string file) {
std::unique_lock<std::mutex> lock(fdMutex);
int fd = -1;
if (fdMap.find(file) == fdMap.end()) {
fd = NEO::SysCalls::open(file.c_str(), O_RDONLY);
@@ -550,4 +551,4 @@ bool SysFsAccessInterface::isRootUser() {
}
} // namespace Sysman
} // namespace L0
} // namespace L0

View File

@@ -13,6 +13,7 @@
#include <map>
#include <memory>
#include <mutex>
#include <vector>
namespace L0 {
@@ -31,6 +32,7 @@ class FdCacheInterface {
std::map<std::string, std::pair<int, uint32_t>> fdMap = {};
private:
std::mutex fdMutex{};
void eraseLeastUsedEntryFromCache();
};
@@ -142,4 +144,4 @@ class SysFsAccessInterface : protected FsAccessInterface {
};
} // namespace Sysman
} // namespace L0
} // namespace L0