Skip to content
Snippets Groups Projects
Commit 7165e0db authored by Martin Karsten's avatar Martin Karsten
Browse files

- separate out busyLock from Cluster's idleLock

parent 6945e1a5
No related branches found
No related tags found
No related merge requests found
...@@ -43,8 +43,8 @@ inline void KernelProcessor::idleLoop(bool irqs) { ...@@ -43,8 +43,8 @@ inline void KernelProcessor::idleLoop(bool irqs) {
if (cluster.setProcessorIdle(*this, terminate)) { if (cluster.setProcessorIdle(*this, terminate)) {
stats->idle.count(); stats->idle.count();
if (!CurrFM().zeroMemory<smallpl>()) halt(!irqs); if (!CurrFM().zeroMemory<smallpl>()) halt(!irqs);
cluster.setProcessorBusy(*this);
} }
cluster.setProcessorBusy(*this);
} }
unreachable(); unreachable();
} }
......
...@@ -101,8 +101,8 @@ inline void SystemProcessor::idleLoop() { ...@@ -101,8 +101,8 @@ inline void SystemProcessor::idleLoop() {
if (reinterpret_cast<FibreCluster&>(cluster).setProcessorIdle(*this, terminate)) { if (reinterpret_cast<FibreCluster&>(cluster).setProcessorIdle(*this, terminate)) {
stats->idle.count(); stats->idle.count();
idleSem.P(); idleSem.P();
cluster.setProcessorBusy(*this);
} }
cluster.setProcessorBusy(*this);
} }
} }
......
...@@ -33,6 +33,7 @@ protected: ...@@ -33,6 +33,7 @@ protected:
SystemLock idleLock; SystemLock idleLock;
ProcessorList idleList; ProcessorList idleList;
volatile size_t idleCount; volatile size_t idleCount;
SystemLock busyLock;
ProcessorList busyList; ProcessorList busyList;
public: public:
...@@ -54,7 +55,7 @@ public: ...@@ -54,7 +55,7 @@ public:
ProcessorRing::insert_after(*ringProc, proc); ProcessorRing::insert_after(*ringProc, proc);
} }
#endif #endif
ScopedLock<SystemLock> sli(idleLock); ScopedLock<SystemLock> sli(busyLock);
busyList.push_back(proc); busyList.push_back(proc);
pCount += 1; pCount += 1;
} }
...@@ -69,7 +70,7 @@ public: ...@@ -69,7 +70,7 @@ public:
if (ringProc == &proc) ringProc = nullptr; if (ringProc == &proc) ringProc = nullptr;
ProcessorRing::remove(proc); ProcessorRing::remove(proc);
#endif #endif
ScopedLock<SystemLock> sli(idleLock); ScopedLock<SystemLock> sli(busyLock);
busyList.remove(proc); busyList.remove(proc);
pCount -= 1; pCount -= 1;
} }
...@@ -92,7 +93,7 @@ public: ...@@ -92,7 +93,7 @@ public:
} }
StackContext* steal() { StackContext* steal() {
ScopedLock<SystemLock> sl(idleLock); ScopedLock<SystemLock> sl(busyLock);
BaseProcessor* p = busyList.front(); BaseProcessor* p = busyList.front();
while (p != busyList.edge()) { while (p != busyList.edge()) {
StackContext* s = p->dequeue<true>(_friend<Cluster>()); StackContext* s = p->dequeue<true>(_friend<Cluster>());
...@@ -107,21 +108,25 @@ public: ...@@ -107,21 +108,25 @@ public:
} }
size_t setProcessorIdle(BaseProcessor& proc, bool terminating) { size_t setProcessorIdle(BaseProcessor& proc, bool terminating) {
ScopedLock<SystemLock> sl(idleLock); busyLock.acquire();
if (!terminating && (backgroundProc.load() || stagingProc.load())) return 0;
busyList.remove(proc); busyList.remove(proc);
busyLock.release();
Runtime::debugS("Processor ", FmtHex(&proc), " on idle list");
ScopedLock<SystemLock> sl(idleLock);
idleList.push_back(proc); idleList.push_back(proc);
idleCount += 1; idleCount += 1;
Runtime::debugS("Processor ", FmtHex(&proc), " on idle list"); if (!terminating && (backgroundProc.load() || stagingProc.load())) return 0;
return idleCount; return idleCount;
} }
void setProcessorBusy(BaseProcessor& proc) { void setProcessorBusy(BaseProcessor& proc) {
ScopedLock<SystemLock> sl(idleLock); idleLock.acquire();
idleCount -= 1; idleCount -= 1;
idleList.remove(proc); idleList.remove(proc);
busyList.push_back(proc); idleLock.release();
Runtime::debugS("Processor ", FmtHex(&proc), " off idle list"); Runtime::debugS("Processor ", FmtHex(&proc), " off idle list");
ScopedLock<SystemLock> sl(busyLock);
busyList.push_back(proc);
} }
BaseProcessor* findIdleProcessorHard() { BaseProcessor* findIdleProcessorHard() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment