3 * - By John Hodge (thePowersGang)
6 * - Low level thread management
23 #define DEBUG_TRACE_SWITCH 0
24 #define DEBUG_DISABLE_DOUBLEFAULT 1
25 #define DEBUG_VERY_SLOW_PERIOD 0
26 #define DEBUG_NOPREEMPT 1
30 #define TIMER_BASE 1193182
31 #if DEBUG_VERY_SLOW_PERIOD
32 # define TIMER_DIVISOR 1193 //~10Hz switch, with 10 quantum = 1s per thread
34 # define TIMER_DIVISOR 11932 //~100Hz
42 extern void APWait(void); // 16-bit AP pause code
43 extern void APStartup(void); // 16-bit AP startup code
44 extern void NewTaskHeader(tThread *Thread, void *Fcn, int nArgs, ...); // Actually takes cdecl args
45 extern Uint Proc_CloneInt(Uint *ESP, Uint32 *CR3, int bNoUserClone);
46 extern Uint32 gaInitPageDir[1024]; // start.asm
47 extern char Kernel_Stack_Top[];
49 extern tThread gThreadZero;
50 extern tProcess gProcessZero;
51 extern void Isr8(void); // Double Fault
52 extern void Proc_ReturnToUser(tVAddr Handler, Uint Argument, tVAddr KernelStack);
53 extern char scheduler_return[]; // Return address in SchedulerBase
54 extern char IRQCommon[]; // Common IRQ handler code
55 extern char IRQCommon_handled[]; // IRQCommon call return location
56 extern char GetEIP_Sched_ret[]; // GetEIP call return location
57 extern void Timer_CallTimers(void);
60 //void ArchThreads_Init(void);
62 void MP_StartAP(int CPU);
63 void MP_SendIPIVector(int CPU, Uint8 Vector);
64 void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode);
66 void Proc_IdleThread(void *Ptr);
67 //void Proc_Start(void);
68 //tThread *Proc_GetCurThread(void);
69 void Proc_ChangeStack(void);
70 // int Proc_NewKThread(void (*Fcn)(void*), void *Data);
71 // int Proc_Clone(Uint *Err, Uint Flags);
72 Uint Proc_MakeUserStack(void);
73 //void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char **EnvP, int DataSize);
74 void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP) NORETURN;
75 void Proc_CallUser(Uint32 UserIP, Uint32 UserSP, const void *StackData, size_t StackDataLen);
76 //void Proc_CallFaultHandler(tThread *Thread);
77 //void Proc_DumpThreadCPUState(tThread *Thread);
78 void Proc_Scheduler(int CPU);
81 // --- Multiprocessing ---
83 volatile int giNumInitingCPUs = 0;
84 volatile Uint32 giMP_TimerCount; // Start Count for Local APIC Timer
85 tAPIC *gpMP_LocalAPIC = NULL;
86 Uint8 gaAPIC_to_CPU[256] = {0};
87 int giProc_BootProcessorID = 0;
88 tTSS gaTSSs[MAX_CPUS]; // TSS Array
90 tCPU gaCPUs[MAX_CPUS] = {
91 {.Current = &gThreadZero}
93 tTSS *gTSSs = NULL; // Pointer to TSS array
95 // --- Error Recovery ---
96 char gaDoubleFaultStack[1024] __attribute__ ((section(".padata")));
97 tTSS gDoubleFault_TSS = {
98 .ESP0 = (Uint)&gaDoubleFaultStack[1024],
100 .CR3 = (Uint)gaInitPageDir - KERNEL_BASE,
102 .ESP = (Uint)&gaDoubleFaultStack[1024],
103 .CS = 0x08, .SS = 0x10,
104 .DS = 0x10, .ES = 0x10,
105 .FS = 0x10, .GS = 0x10,
110 * \fn void ArchThreads_Init(void)
111 * \brief Starts the process scheduler
113 void ArchThreads_Init(void)
115 // Mark BSP as active
119 // -- Initialise Multiprocessing
120 const void *mpfloatptr = MPTable_LocateFloatPtr();
123 giNumCPUs = MPTable_FillCPUs(mpfloatptr, gaCPUs, MAX_CPUS, &giProc_BootProcessorID);
124 for( int i = 0; i < giNumCPUs; i ++ )
126 // TODO: Determine if there's an overlap
127 gaAPIC_to_CPU[gaCPUs[i].APICID] = i;
133 Log("No MP Table was found, assuming uniprocessor");
142 #if !DEBUG_DISABLE_DOUBLEFAULT
143 // Initialise Double Fault TSS
144 gGDT[5].BaseLow = (Uint)&gDoubleFault_TSS & 0xFFFF;
145 gGDT[5].BaseMid = (Uint)&gDoubleFault_TSS >> 16;
146 gGDT[5].BaseHi = (Uint)&gDoubleFault_TSS >> 24;
148 // Set double fault IDT to use the new TSS
149 gIDT[8].OffsetLo = 0;
151 gIDT[8].Flags = 0x8500;
152 gIDT[8].OffsetHi = 0;
155 // Set timer frequency
156 outb(0x43, 0x34); // Set Channel 0, Low/High, Rate Generator
157 outb(0x40, TIMER_DIVISOR&0xFF); // Low Byte of Divisor
158 outb(0x40, (TIMER_DIVISOR>>8)&0xFF); // High Byte
160 Log_Debug("Proc", "PIT Frequency %i.%03i Hz",
161 TIMER_BASE/TIMER_DIVISOR,
162 ((Uint64)TIMER_BASE*1000/TIMER_DIVISOR)%1000
166 // Get the count setting for APIC timer
167 Log("Determining APIC Count");
168 __asm__ __volatile__ ("sti");
169 while( giMP_TimerCount == 0 ) __asm__ __volatile__ ("hlt");
170 __asm__ __volatile__ ("cli");
171 Log("APIC Count %i", giMP_TimerCount);
173 Uint64 freq = giMP_TimerCount;
175 freq /= TIMER_DIVISOR;
176 if( (freq /= 1000) < 2*1000)
177 Log("Bus Frequency %i KHz", freq);
178 else if( (freq /= 1000) < 2*1000)
179 Log("Bus Frequency %i MHz", freq);
180 else if( (freq /= 1000) < 2*1000)
181 Log("Bus Frequency %i GHz", freq);
183 Log("Bus Frequency %i THz", freq);
186 // Initialise Normal TSS(s)
187 for(int pos=0;pos<giNumCPUs;pos++)
192 gTSSs[pos].SS0 = 0x10;
193 gTSSs[pos].ESP0 = 0; // Set properly by scheduler
194 gGDT[6+pos].BaseLow = ((Uint)(&gTSSs[pos])) & 0xFFFF;
195 gGDT[6+pos].BaseMid = ((Uint)(&gTSSs[pos]) >> 16) & 0xFFFF;
196 gGDT[6+pos].BaseHi = ((Uint)(&gTSSs[pos])) >> 24;
201 // Load the BSP's TSS
202 __asm__ __volatile__ ("ltr %%ax"::"a"(0x30));
203 // Set Current Thread and CPU Number in DR0 and DR1
204 __asm__ __volatile__ ("mov %0, %%db0"::"r"(&gThreadZero));
205 __asm__ __volatile__ ("mov %0, %%db1"::"r"(0));
207 gaCPUs[0].Current = &gThreadZero;
208 gThreadZero.CurCPU = 0;
210 gProcessZero.MemState.CR3 = (Uint)gaInitPageDir - KERNEL_BASE;
212 // Create Per-Process Data Block
213 if( !MM_Allocate(MM_PPD_CFG) )
215 Panic("OOM - No space for initial Per-Process Config");
218 // Initialise SSE support
219 Proc_InitialiseSSE();
229 void MP_StartAP(int CPU)
231 Log_Log("Proc", "Starting AP %i (APIC %i)", CPU, gaCPUs[CPU].APICID);
233 // Set location of AP startup code and mark for a warm restart
234 *(Uint16*)(KERNEL_BASE|0x467) = (Uint)&APWait - (KERNEL_BASE|0xFFFF0);
235 *(Uint16*)(KERNEL_BASE|0x469) = 0xFFFF;
236 outb(0x70, 0x0F); outb(0x71, 0x0A); // Set warm reset flag
237 MP_SendIPI(gaCPUs[CPU].APICID, 0, 5); // Init IPI
239 // Take a quick nap (20ms)
242 // TODO: Use a better address, preferably registered with the MM
243 // - MM_AllocDMA mabye?
245 *(Uint8*)(KERNEL_BASE|0x11000) = 0xEA; // Far JMP
246 *(Uint16*)(KERNEL_BASE|0x11001) = (Uint16)(tVAddr)&APStartup + 0x10; // IP
247 *(Uint16*)(KERNEL_BASE|0x11003) = 0xFFFF; // CS
251 // Send a Startup-IPI to make the CPU execute at 0x11000 (which we
253 MP_SendIPI(gaCPUs[CPU].APICID, 0x11, 6); // StartupIPI
255 tTime timeout = now() + 2;
256 while( giNumInitingCPUs && now() > timeout )
259 if( giNumInitingCPUs == 0 )
262 // First S-IPI failed, send again
263 MP_SendIPI(gaCPUs[CPU].APICID, 0x11, 6);
265 while( giNumInitingCPUs && now() > timeout )
267 if( giNumInitingCPUs == 0 )
270 Log_Notice("Proc", "CPU %i (APIC %x) didn't come up", CPU, gaCPUs[CPU].APICID);
273 giNumInitingCPUs = 0;
276 void MP_SendIPIVector(int CPU, Uint8 Vector)
278 MP_SendIPI(gaCPUs[CPU].APICID, Vector, 0);
282 * \brief Send an Inter-Processor Interrupt
283 * \param APICID Processor's Local APIC ID
284 * \param Vector Argument of some kind
285 * \param DeliveryMode Type of signal
286 * \note 3A 10.5 "APIC/Handling Local Interrupts"
288 void MP_SendIPI(Uint8 APICID, int Vector, int DeliveryMode)
293 val = (Uint)APICID << 24;
294 gpMP_LocalAPIC->ICR[1].Val = val;
296 val = ((DeliveryMode & 7) << 8) | (Vector & 0xFF);
297 gpMP_LocalAPIC->ICR[0].Val = val;
301 void Proc_IdleThread(void *Ptr)
303 tCPU *cpu = &gaCPUs[GetCPUNum()];
304 cpu->Current->ThreadName = strdup("Idle Thread");
305 Threads_SetPriority( cpu->Current, -1 ); // Never called randomly
306 cpu->Current->Quantum = 1; // 1 slice quantum
308 __asm__ __volatile__ ("sti"); // Make sure interrupts are enabled
309 __asm__ __volatile__ ("hlt");
315 * \fn void Proc_Start(void)
316 * \brief Start process scheduler
318 void Proc_Start(void)
321 // BSP still should run the current task
322 gaCPUs[giProc_BootProcessorID].Current = &gThreadZero;
324 __asm__ __volatile__ ("sti");
327 for( int i = 0; i < giNumCPUs; i ++ )
329 if(i != giProc_BootProcessorID)
330 gaCPUs[i].Current = NULL;
333 Proc_NewKThread(Proc_IdleThread, &gaCPUs[i]);
336 if( i != giProc_BootProcessorID ) {
342 Proc_NewKThread(Proc_IdleThread, &gaCPUs[0]);
345 gaCPUs[0].Current = &gThreadZero;
347 // Start Interrupts (and hence scheduler)
348 __asm__ __volatile__("sti");
350 MM_FinishVirtualInit();
354 * \fn tThread *Proc_GetCurThread(void)
355 * \brief Gets the current thread
357 tThread *Proc_GetCurThread(void)
360 return gaCPUs[ GetCPUNum() ].Current;
362 return gaCPUs[ 0 ].Current;
367 * \fn void Proc_ChangeStack(void)
368 * \brief Swaps the current stack for a new one (in the proper stack reigon)
370 void Proc_ChangeStack(void)
374 Uint curBase, newBase;
376 __asm__ __volatile__ ("mov %%esp, %0":"=r"(esp));
377 __asm__ __volatile__ ("mov %%ebp, %0":"=r"(ebp));
382 newBase = MM_NewKStack();
385 Panic("What the?? Unable to allocate space for initial kernel stack");
389 curBase = (Uint)&Kernel_Stack_Top;
391 LOG("curBase = 0x%x, newBase = 0x%x", curBase, newBase);
393 // Get ESP as a used size
395 LOG("memcpy( %p, %p, 0x%x )", (void*)(newBase - esp), (void*)(curBase - esp), esp );
397 memcpy( (void*)(newBase - esp), (void*)(curBase - esp), esp );
398 // Get ESP as an offset in the new stack
401 ebp = newBase - (curBase - ebp);
403 // Repair EBPs & Stack Addresses
404 // Catches arguments also, but may trash stack-address-like values
405 for(tmpEbp = esp; tmpEbp < newBase; tmpEbp += 4)
407 if(oldEsp < *(Uint*)tmpEbp && *(Uint*)tmpEbp < curBase)
408 *(Uint*)tmpEbp += newBase - curBase;
411 Proc_GetCurThread()->KernelStack = newBase;
413 __asm__ __volatile__ ("mov %0, %%esp"::"r"(esp));
414 __asm__ __volatile__ ("mov %0, %%ebp"::"r"(ebp));
417 void Proc_ClearProcess(tProcess *Process)
419 MM_ClearSpace(Process->MemState.CR3);
422 void Proc_ClearThread(tThread *Thread)
424 if(Thread->SavedState.SSE) {
425 free(Thread->SavedState.SSE);
426 Thread->SavedState.SSE = NULL;
430 tTID Proc_NewKThread(void (*Fcn)(void*), void *Data)
435 newThread = Threads_CloneTCB(0);
436 if(!newThread) return -1;
439 newThread->KernelStack = MM_NewKStack();
441 if(newThread->KernelStack == 0) {
446 esp = newThread->KernelStack;
447 *(Uint*)(esp-=4) = (Uint)Data; // Data (shadowed)
448 *(Uint*)(esp-=4) = 1; // Number of params
449 *(Uint*)(esp-=4) = (Uint)Fcn; // Function to call
450 *(Uint*)(esp-=4) = (Uint)newThread; // Thread ID
452 newThread->SavedState.ESP = esp;
453 newThread->SavedState.EIP = (Uint)&NewTaskHeader;
454 newThread->SavedState.SSE = NULL;
455 // Log("New (KThread) %p, esp = %p", newThread->SavedState.EIP, newThread->SavedState.ESP);
458 Threads_AddActive(newThread);
460 return newThread->TID;
464 * \fn int Proc_Clone(Uint *Err, Uint Flags)
465 * \brief Clone the current process
467 tPID Proc_Clone(Uint Flags)
470 tThread *cur = Proc_GetCurThread();
474 if( !(Flags & CLONE_VM) ) {
475 Log_Error("Proc", "Proc_Clone: Don't leave CLONE_VM unset, use Proc_NewKThread instead");
480 newThread = Threads_CloneTCB(Flags);
481 if(!newThread) return -1;
483 newThread->KernelStack = cur->KernelStack;
486 eip = Proc_CloneInt(&newThread->SavedState.ESP, &newThread->Process->MemState.CR3, Flags & CLONE_NOUSER);
490 newThread->SavedState.EIP = eip;
491 newThread->SavedState.SSE = NULL;
492 newThread->SavedState.bSSEModified = 0;
495 if( newThread->Process->MemState.CR3 == 0 ) {
496 Log_Error("Proc", "Proc_Clone: MM_Clone failed");
497 Threads_Delete(newThread);
501 // Add the new thread to the run queue
502 Threads_AddActive(newThread);
503 return newThread->TID;
507 * \fn int Proc_SpawnWorker(void)
508 * \brief Spawns a new worker thread
510 tThread *Proc_SpawnWorker(void (*Fcn)(void*), void *Data)
512 Uint stack_contents[4];
513 LOG("(Fcn=%p,Data=%p)", Fcn, Data);
516 tThread *new = Threads_CloneThreadZero();
519 Warning("Proc_SpawnWorker - Out of heap space!\n");
523 // Create the stack contents
524 stack_contents[3] = (Uint)Data;
525 stack_contents[2] = 1;
526 stack_contents[1] = (Uint)Fcn;
527 stack_contents[0] = (Uint)new;
529 // Create a new worker stack (in PID0's address space)
530 new->KernelStack = MM_NewWorkerStack(stack_contents, sizeof(stack_contents));
531 LOG("new->KernelStack = %p", new->KernelStack);
533 // Save core machine state
534 new->SavedState.ESP = new->KernelStack - sizeof(stack_contents);
535 new->SavedState.EIP = (Uint)NewTaskHeader;
536 new->SavedState.SSE = NULL;
537 new->SavedState.bSSEModified = 0;
540 new->Status = THREAD_STAT_PREINIT;
541 Threads_AddActive( new );
542 LOG("Added to active");
548 * \fn Uint Proc_MakeUserStack(void)
549 * \brief Creates a new user stack
551 Uint Proc_MakeUserStack(void)
554 Uint base = USER_STACK_TOP - USER_STACK_SZ;
556 // Check Prospective Space
557 for( i = USER_STACK_SZ >> 12; i--; )
558 if( MM_GetPhysAddr( (void*)(base + (i<<12)) ) != 0 )
561 if(i != -1) return 0;
563 // Allocate Stack - Allocate incrementally to clean up MM_Dump output
564 for( i = 0; i < USER_STACK_SZ/0x1000; i++ )
566 if( !MM_Allocate( base + (i<<12) ) )
568 Warning("OOM: Proc_MakeUserStack");
573 return base + USER_STACK_SZ;
576 void Proc_StartUser(Uint Entrypoint, Uint Base, int ArgC, const char **ArgV, int DataSize)
580 const char **envp = NULL;
583 // Copy data to the user stack and free original buffer
584 stack = (void*)Proc_MakeUserStack();
585 stack -= (DataSize+sizeof(*stack)-1)/sizeof(*stack);
586 memcpy( stack, ArgV, DataSize );
589 // Adjust Arguments and environment
592 Uint delta = (Uint)stack - (Uint)ArgV;
593 ArgV = (const char**)stack;
594 for( i = 0; ArgV[i]; i++ ) ArgV[i] += delta;
596 for( i = 0; envp[i]; i++ ) envp[i] += delta;
599 // User Mode Segments
600 ss = 0x23; cs = 0x1B;
603 *--stack = (Uint)envp;
604 *--stack = (Uint)ArgV;
605 *--stack = (Uint)ArgC;
608 Proc_StartProcess(ss, (Uint)stack, 0x202, cs, Entrypoint);
611 void Proc_StartProcess(Uint16 SS, Uint Stack, Uint Flags, Uint16 CS, Uint IP)
613 Uint *stack = (void*)Stack;
614 *--stack = SS; //Stack Segment
615 *--stack = Stack; //Stack Pointer
616 *--stack = Flags; //EFLAGS (Resvd (0x2) and IF (0x20))
617 *--stack = CS; //Code Segment
620 *--stack = 0xAAAAAAAA; // eax
621 *--stack = 0xCCCCCCCC; // ecx
622 *--stack = 0xDDDDDDDD; // edx
623 *--stack = 0xBBBBBBBB; // ebx
624 *--stack = 0xD1D1D1D1; // edi
625 *--stack = 0x54545454; // esp - NOT POPED
626 *--stack = 0x51515151; // esi
627 *--stack = 0xB4B4B4B4; // ebp
634 __asm__ __volatile__ (
635 "mov %%eax,%%esp;\n\t" // Set stack pointer
641 "iret;\n\t" : : "a" (stack));
645 void Proc_CallUser(Uint32 UserIP, Uint32 UserSP, const void *StackData, size_t StackDataLen)
647 if( UserSP < StackDataLen )
649 if( !CheckMem( (void*)(UserSP - StackDataLen), StackDataLen ) )
651 memcpy( (void*)(UserSP - StackDataLen), StackData, StackDataLen );
653 __asm__ __volatile__ (
654 "mov $0x23,%%ax;\n\t"
655 "mov %%ax, %%ds;\n\t"
656 "mov %%ax, %%es;\n\t"
657 "mov %%ax, %%fs;\n\t"
658 "mov %%ax, %%gs;\n\t"
666 : "r" (UserIP), "r" (UserSP - StackDataLen)
674 * \brief Calls a signal handler in user mode
675 * \note Used for signals
677 void Proc_CallFaultHandler(tThread *Thread)
679 // Rewinds the stack and calls the user function
681 Proc_ReturnToUser( Thread->FaultHandler, Thread->CurFaultNum, Thread->KernelStack );
685 void Proc_DumpThreadCPUState(tThread *Thread)
687 if( Thread->CurCPU > -1 )
689 int maxBacktraceDistance = 6;
693 if( Thread->CurCPU != GetCPUNum() ) {
694 Log(" Currently running");
698 // Backtrace to find the IRQ entrypoint
699 // - This will usually only be called by an IRQ, so this should
701 __asm__ __volatile__ ("mov %%ebp, %0" : "=r" (stack));
702 while( maxBacktraceDistance -- )
704 if( !CheckMem(stack, 8) ) {
711 if( stack[1] == (tVAddr)&IRQCommon_handled ) {
712 regs = (void*)stack[2];
716 stack = (void*)stack[0];
720 Log(" Unable to find IRQ Entry");
724 Log(" at %04x:%08x [EAX:%x]", regs->cs, regs->eip, regs->eax);
725 Error_Backtrace(regs->eip, regs->ebp);
729 tVAddr diffFromScheduler = Thread->SavedState.EIP - (tVAddr)SwitchTasks;
730 tVAddr diffFromClone = Thread->SavedState.EIP - (tVAddr)Proc_CloneInt;
731 tVAddr diffFromSpawn = Thread->SavedState.EIP - (tVAddr)NewTaskHeader;
733 if( diffFromClone > 0 && diffFromClone < 40 ) // When I last checked, .newTask was at .+27
735 Log(" Creating process");
739 if( diffFromSpawn == 0 )
741 Log(" Creating thread");
745 if( diffFromScheduler > 0 && diffFromScheduler < 128 ) // When I last checked, GetEIP was at .+0x30
748 Log(" At %04x:%08x", Thread->SavedState.UserCS, Thread->SavedState.UserEIP);
752 Log(" Just created (unknown %p)", Thread->SavedState.EIP);
755 void Proc_Reschedule(void)
757 tThread *nextthread, *curthread;
758 int cpu = GetCPUNum();
760 // TODO: Wait for the lock?
761 if(IS_LOCKED(&glThreadListLock)) return;
763 curthread = Proc_GetCurThread();
765 nextthread = Threads_GetNextToRun(cpu, curthread);
767 if(!nextthread || nextthread == curthread)
770 #if DEBUG_TRACE_SWITCH
771 // HACK: Ignores switches to the idle threads
772 if( nextthread->TID == 0 || nextthread->TID > giNumCPUs )
774 LogF("\nSwitching CPU %i to %p (%i %s) - CR3 = 0x%x, EIP = %p, ESP = %p\n",
776 nextthread, nextthread->TID, nextthread->ThreadName,
777 nextthread->Process->MemState.CR3,
778 nextthread->SavedState.EIP,
779 nextthread->SavedState.ESP
781 LogF("OldCR3 = %P\n", curthread->Process->MemState.CR3);
786 gaCPUs[cpu].Current = nextthread;
787 gaCPUs[cpu].LastTimerThread = NULL;
788 gTSSs[cpu].ESP0 = nextthread->KernelStack-4;
789 __asm__ __volatile__("mov %0, %%db0\n\t" : : "r"(nextthread) );
791 // Save FPU/MMX/XMM/SSE state
792 if( curthread && curthread->SavedState.SSE )
794 Proc_SaveSSE( ((Uint)curthread->SavedState.SSE + 0xF) & ~0xF );
795 curthread->SavedState.bSSEModified = 0;
802 nextthread->SavedState.ESP, &curthread->SavedState.ESP,
803 nextthread->SavedState.EIP, &curthread->SavedState.EIP,
804 nextthread->Process->MemState.CR3
810 nextthread->SavedState.ESP, 0,
811 nextthread->SavedState.EIP, 0,
812 nextthread->Process->MemState.CR3
820 * \fn void Proc_Scheduler(int CPU)
821 * \brief Swap current thread and clears dead threads
823 void Proc_Scheduler(int CPU)
827 gpMP_LocalAPIC->EOI.Val = 0;
831 __asm__ __volatile__ ("sti");
833 // Call the timer update code
837 // If two ticks happen within the same task, and it's not an idle task, swap
838 if( gaCPUs[CPU].Current->TID > giNumCPUs && gaCPUs[CPU].Current == gaCPUs[CPU].LastTimerThread )
843 gaCPUs[CPU].LastTimerThread = gaCPUs[CPU].Current;
848 EXPORT(Proc_SpawnWorker);