fixed the "user" kernel module getting the wrong IDs when creating tasks

when the user kernel module creates a task, it used to count the amount
of processes in the system, which can lead to some processes having the
same IDs as another, which causes havoc. this has been fixed by using
the ID counter in the tsched kernel module.
This commit is contained in:
Ponali
2025-10-30 17:48:16 +01:00
parent 86f825d14b
commit f5fcc84903
2 changed files with 30 additions and 8 deletions
+18 -3
View File
@@ -38,17 +38,32 @@ function module.init()
end
local task = coroutine.create(func)
local taskInfo = { ["task"] = task, ["name"] = name, ["id"] = #_PUBLIC.tsched.getTasks() + 1, ["user"] = userId}
local taskInfo = { ["task"] = task, ["name"] = name, ["id"] = tsched.idCounter, ["user"] = userId }
if type(tsched.currentTask) == "table" and type(tsched.currentTask.id) == "number" then
taskInfo.parent = tsched.currentTask.id
else
log.kernel.info("debug: tsched.currentTask is " .. require("serialize").table(tsched.currentTask))
end
table.insert(tsched.tasks, taskInfo)
if taskInfo.parent then
log.kernel.info(
("[tsched (user)] Created task %s (PID %d) by parent PID %d as UID %d"):format(name, #_PUBLIC.tsched.getTasks(), taskInfo.parent, taskInfo.user)
("[tsched (user)] Created task %s (PID %d) by parent PID %d as UID %d"):format(
name,
#_PUBLIC.tsched.getTasks(),
taskInfo.parent,
taskInfo.user
)
)
log.kernel.info(
string.format(
"[tsched (user)] Created task %s (PID %d) as UID %d (no parent found)",
name,
#_PUBLIC.tsched.getTasks(),
taskInfo.user
)
)
log.kernel.info(string.format("[tsched (user)] Created task %s (PID %d) as UID %d (no parent found)", name, #_PUBLIC.tsched.getTasks(), taskInfo.user))
end
tsched.idCounter = tsched.idCounter + 1
return task, taskInfo
end
end