| 44 | } |
| 45 | |
| 46 | void InsertNewThreadIntoQueue(thread_t* thread){ |
| 47 | CPU* cpu = SMP::cpus[0]; |
| 48 | for(unsigned i = 1; i < SMP::processorCount; i++){ |
| 49 | if(SMP::cpus[i]->runQueue->get_length() < cpu->runQueue->get_length()) { |
| 50 | cpu = SMP::cpus[i]; |
| 51 | } |
| 52 | |
| 53 | if(!cpu->runQueue->get_length()){ |
| 54 | break; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | //Log::Info("Inserting thread into run queue of CPU %d", cpu->id); |
| 59 | |
| 60 | asm("sti"); |
| 61 | acquireLock(&cpu->runQueueLock); |
| 62 | asm("cli"); |
| 63 | cpu->runQueue->add_back(thread); |
| 64 | releaseLock(&cpu->runQueueLock); |
| 65 | asm("sti"); |
| 66 | } |
| 67 | |
| 68 | void Initialize() { |
| 69 | processes = new List<process_t*>(); |
no test coverage detected