MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / InsertNewThreadIntoQueue

Function InsertNewThreadIntoQueue

Kernel/src/arch/x86_64/scheduler.cpp:46–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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*>();

Callers 3

CreateProcessFunction · 0.85
CreateChildThreadFunction · 0.85
CreateELFProcessFunction · 0.85

Calls 2

get_lengthMethod · 0.45
add_backMethod · 0.45

Tested by

no test coverage detected