Unverified Commit 2c0f2f45 authored by PhoeniX's avatar PhoeniX

Make instance pointers volatile

parent d1bb756f
Pipeline #1848 passed with stages
in 32 seconds
......@@ -170,7 +170,7 @@ const size_t ConsoleDisplay::size = ConsoleDisplay::top - ConsoleDisplay::base;
static Display *getSerialDisplay();
static SerialDisplay serialConsole;
Display *Display::instance = getSerialDisplay();
volatile Display *Display::instance = getSerialDisplay();
Mutex Display::instanceMutex;
static Display *getSerialDisplay() { return &serialConsole; }
......@@ -209,10 +209,10 @@ void Display::setup() {
}
Display *Display::getInstance() {
if (instance) return instance;
if (instance) return const_cast<Display*>(instance);
Mutex::CriticalLock lock(instanceMutex);
if (!instance) setup();
return instance;
return const_cast<Display*>(instance);
}
Display::~Display() {}
......@@ -8,7 +8,7 @@
class Display {
private:
static Mutex instanceMutex;
static Display *instance;
static volatile Display *instance;
static void setup();
protected:
Mutex mutex;
......
......@@ -8,13 +8,13 @@
#include "pagetable.hpp"
Mutex ACPI::controllerMutex;
ACPI* ACPI::controller = nullptr;
volatile ACPI* ACPI::controller = nullptr;
ACPI* ACPI::getController() {
if (controller) return controller;
if (controller) return const_cast<ACPI*>(controller);
Mutex::CriticalLock lock(controllerMutex);
if (!controller) controller = new ACPI();
return controller;
return const_cast<ACPI*>(controller);
}
ACPI::ACPI() {
......@@ -29,7 +29,7 @@ ACPI::ACPI() {
ioApicAddr = nullptr;
const uint64_t *ptr = nullptr;
if (!ptr && (ptr = static_cast<const uint64_t*>(EFI::getACPI2Addr()))) {
if (nullptr != (ptr = static_cast<const uint64_t*>(EFI::getACPI2Addr()))) {
Pagetable::map(ptr);
Pagetable::map(ptr + 1);
if ((*ptr != ACPI_SIG_RTP_DSR) || !ParseRsdp(ptr)) ptr = nullptr;
......
......@@ -105,7 +105,7 @@ class ACPI {
private:
static Mutex controllerMutex;
static ACPI *controller;
static volatile ACPI *controller;
char *localApicAddr, *ioApicAddr;
uint8_t ioApicMaxCount;
......
......@@ -12,7 +12,7 @@ class ModuleManager {
char *name, *version, *description, *requirements, *developer;
};
static Mutex managerMutex;
static ModuleManager* manager;
static volatile ModuleManager* manager;
void parseInternal();
void parseInitRD();
void loadStream(Stream *stream);
......
......@@ -16,7 +16,7 @@ class ProcessManager {
};
static Mutex managerMutex;
static ProcessManager* manager;
static volatile ProcessManager* manager;
ProcessManager();
QueuedThread *nextThread, *lastThread;
......
......@@ -6,6 +6,7 @@
#include "readelf.hpp"
#include "multiboot_info.hpp"
volatile ModuleManager* ModuleManager::manager = nullptr;
Mutex ModuleManager::managerMutex;
bool ModuleManager::parseModuleInfo(ModuleInfo *info, Process *process) {
......@@ -122,7 +123,6 @@ bool ModuleManager::bindRequirements(const char *reqs, Process *process) {
return 1;
}
ModuleManager* ModuleManager::manager = nullptr;
void ModuleManager::loadStream(Stream *stream) {
Stream *sub = stream;
Process *process;
......@@ -190,8 +190,8 @@ void ModuleManager::init() {
}
ModuleManager* ModuleManager::getManager() {
if (manager) return manager;
if (manager) return const_cast<ModuleManager*>(manager);
Mutex::Lock lock(managerMutex);
if (!manager) manager = new ModuleManager();
return manager;
return const_cast<ModuleManager*>(manager);
}
......@@ -13,13 +13,13 @@ void __attribute((naked)) ProcessManager::process_loop() {
}
Mutex ProcessManager::managerMutex;
ProcessManager* ProcessManager::manager = nullptr;
volatile ProcessManager* ProcessManager::manager = nullptr;
ProcessManager* ProcessManager::getManager() {
if (manager) return manager;
if (manager) return const_cast<ProcessManager*>(manager);
Mutex::CriticalLock lock(managerMutex);
if (!manager) manager = new ProcessManager();
return manager;
return const_cast<ProcessManager*>(manager);
}
ProcessManager::ProcessManager() {
......
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