Fix ghost threads in CPU

* kernel: Make sf9 return TSTATE_FREE for invalid slots: 0, >255, free.
* menu: Ignore free slots even if other fields of proc_info look valid.
        Documentation (sysfuncs.txt) clearly states all the other info
        as invalid when slot_state is TSTATE_FREE.
* taskbar: Same as menu.
* cmm/lib/*: Same as menu.
* programs/macros.inc: Add TSTATE_* macros.
This commit is contained in:
2025-02-01 02:53:14 +00:00
parent 6933ee64cd
commit d235c8914c
6 changed files with 39 additions and 28 deletions

View File

@@ -2320,23 +2320,16 @@ sys_cpuusage:
jne .no_who_am_i
mov ecx, [current_slot_idx]
.no_who_am_i:
jecxz .empty_slot
; default value for (slot == 0) and (slot > 255)
mov [ebx+process_information.slot_state], TSTATE_FREE
test ecx, ecx
jz .nofillbuf
cmp ecx, max_processes
ja .empty_slot
ja .nofillbuf
mov edx, ecx
shl edx, BSF sizeof.APPDATA
cmp [SLOT_BASE+edx+APPDATA.state], TSTATE_FREE
jnz .thread_found
.empty_slot:
; zero buffer for an empty slot
push edi
xor eax, eax
mov edi, ebx
movi ecx, sizeof.process_information
rep stosb
pop edi
jmp .nofillbuf
.thread_found:
jz .nofillbuf
; +4: word: position of the window of thread in the window stack
mov ax, [WIN_STACK + ecx * 2]
mov [ebx+process_information.window_stack_position], ax