Skip to content

Commit

Permalink
Current process pointer getter
Browse files Browse the repository at this point in the history
  • Loading branch information
djphoenix committed Apr 24, 2017
1 parent 8383b61 commit 5c31e0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/process/include/processmanager.hpp
Expand Up @@ -45,6 +45,7 @@ class ProcessManager {
uint64_t RegisterProcess(Process *process);
void queueThread(Process *process, Thread *thread);
void dequeueThread(Thread *thread);
Process *currentProcess();
static ProcessManager* getManager();
static void NORETURN process_loop();
};
10 changes: 10 additions & 0 deletions src/process/processmanager.cpp
Expand Up @@ -194,3 +194,13 @@ void ProcessManager::dequeueThread(Thread *thread) {
processSwitchMutex.release();
LeaveCritical(t);
}

Process *ProcessManager::currentProcess() {
uint64_t cpuid = ACPI::getController()->getCPUID();
uint64_t t = EnterCritical();
processSwitchMutex.lock();
QueuedThread *curr = cpuThreads[cpuid];
processSwitchMutex.release();
LeaveCritical(t);
return curr ? curr->process : 0;
}

0 comments on commit 5c31e0b

Please sign in to comment.