MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / spinlock_smp_test

Function spinlock_smp_test

tests/system_test/spinlock_test.cpp:127–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125std::atomic<int> finished_cores = 0;
126
127auto spinlock_smp_test() -> bool {
128 for (int i = 0; i < 10000; ++i) {
129 (void)smp_lock.Lock();
130 shared_counter++;
131 (void)smp_lock.UnLock();
132 }
133
134 int finished = finished_cores.fetch_add(1) + 1;
135 int total_cores = BasicInfoSingleton::instance().core_count;
136
137 if (finished == total_cores) {
138 bool passed = (shared_counter == total_cores * 10000);
139 if (passed) {
140 klog::Info(" All cores finished. shared_counter = {}. OK.",
141 shared_counter);
142 } else {
143 klog::Err(" All cores finished. shared_counter = {}. EXPECTED {}. FAIL.",
144 shared_counter, total_cores * 10000);
145 }
146 return passed;
147 }
148
149 return true;
150}
151
152constexpr int BUFFER_SIZE = 8192;
153int shared_buffer[BUFFER_SIZE];

Callers 1

spinlock_testFunction · 0.85

Calls 4

InfoFunction · 0.85
ErrFunction · 0.85
LockMethod · 0.45
UnLockMethod · 0.45

Tested by

no test coverage detected