From 75fe8b68da5c6464a725429f7f4b58b33005d286 Mon Sep 17 00:00:00 2001 From: "Rustem Gimadutdinov (rgimad)" Date: Mon, 14 Jun 2021 11:48:48 +0000 Subject: [PATCH] refactoring pid_to_slot: - use constants instead of hardcoded values - add more comments git-svn-id: svn://kolibrios.org@8851 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/const.inc | 1 + kernel/trunk/core/taskman.inc | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index 501e616f2a..e3b60e4a63 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -219,6 +219,7 @@ OS_BASE = 0x80000000 window_data = OS_BASE + 0x0001000 +TASK_TABLE = OS_BASE + 0x0003000 CURRENT_TASK = OS_BASE + 0x0003000 TASK_COUNT = OS_BASE + 0x0003004 TASK_BASE = OS_BASE + 0x0003010 diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index 2c64376041..b981fcb636 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -484,15 +484,19 @@ pid_to_slot: push ebx push ecx mov ebx, [TASK_COUNT] - shl ebx, 5 + shl ebx, 5 ; ebx *= 32 (32 is size of TASKDATA struct) + ; add 2*32 cause: + ; 0x80003000 - 0x80003020 isnt a task actually + ; skip first process in the task table mov ecx, 2*32 .loop: -;ecx=offset of current process info entry -;ebx=maximum permitted offset - cmp byte [CURRENT_TASK+ecx+0xa], 9 +;ecx = offset of current process info entry +;ebx = maximum permitted offset + ; state 9 means "not used" + cmp byte [TASK_TABLE+ecx+TASKDATA.state], 9 jz .endloop ;skip empty slots - cmp [CURRENT_TASK+ecx+0x4], eax;check PID + cmp [TASK_TABLE+ecx+TASKDATA.pid], eax;check PID jz .pid_found .endloop: add ecx, 32