内核 intr/syscall.vp:删除 WAIT_WINDOW/CREATE_WINDOW/DRAW_TEXT/GET_WINBUF/WIN_FLUSH/POLL_EVENT/SET_CURSOR/SET_TITLE/SET_GEOMETRY/SET_RESIZABLE/GET_WIN_SIZE 的枚举项、派发分支与对应函数;去掉 services.desktop 依赖;EXIT 不再拆窗口(内核已不持有窗口语义)。 删除 VKernel/Kernel/services/desktop.vp(~2900 行内核桌面/合成/输入分发);main.vp 不再启动 desktop 线程,只保留一次 fb 局部量一致性校验。剩余 syscall = Linux 对齐段 + 8 个待 devfs 化的私有项(SERIAL_PUTS/TELL/SIZE/OPENDIR/READDIR/CLOSEDIR/LOAD_SO/SO_CALL1)。 SDK:yield_cpu() 从 WAIT_WINDOW(0,2) 改为 Linux 对齐的 sched_yield(内核同样是 try_reschedule);syscall.vp 同步删掉 11 个 UI 成员。 explorer:关闭按钮改为先通知 CLOSE 再把槽位 used=0 —— window.vp 的 is_active() 见 used==0 返回 0,app 的 while is_active() 自然退出;像素缓冲不复用(bump 分配)⇒ 无别名风险。至此输入只剩 explorer 一家在读(内核桌面已删),两个合成器之争结束。
76 lines
2.2 KiB
Plaintext
76 lines
2.2 KiB
Plaintext
from . import syscall as syscall
|
||
|
||
|
||
def exit(code: int):
|
||
syscall._syscall1(uint64(syscall.Syscall.EXIT), uint64(code))
|
||
|
||
def thread_exit():
|
||
"""当前用户线程显式退出:内核回收其用户栈并标记线程结束(不返回)。"""
|
||
syscall._syscall0(uint64(syscall.Syscall.THREAD_EXIT))
|
||
|
||
def yield_cpu():
|
||
# S3e:原走 WAIT_WINDOW(0,2)(UI 私有 syscall,已随内核 UI 一并删除)。
|
||
# 语义等价的是 Linux 对齐段里的 sched_yield ⇒ 内核同样是 try_reschedule()。
|
||
syscall._syscall0(uint64(syscall.Syscall.YIELD))
|
||
|
||
def get_pid() -> int:
|
||
"""当前进程 pid(getpid)。/dev/desk 的事件按 pid 过滤,建窗前就要拿到它。"""
|
||
return int(syscall._syscall0(uint64(syscall.Syscall.GETPID)))
|
||
|
||
def spawn(path: const str, blocking: int = 0) -> int:
|
||
return int(syscall._syscall2(uint64(syscall.Syscall.SPAWN), uint64(path), uint64(blocking)))
|
||
|
||
def thread_create(func: rawptr, arg: rawptr = None) -> int:
|
||
return int(syscall._syscall2(uint64(syscall.Syscall.THREAD_CREATE), uint64(func), uint64(arg)))
|
||
|
||
|
||
class Thread:
|
||
_tid: int
|
||
_func: rawptr
|
||
_arg: rawptr
|
||
_running: int
|
||
|
||
def __init__(self, func: rawptr, arg: rawptr = None):
|
||
self._func = func
|
||
self._arg = arg
|
||
self._tid = -1
|
||
self._running = 0
|
||
|
||
def start(self) -> int:
|
||
if self._running: return -1
|
||
self._tid = thread_create(self._func, self._arg)
|
||
if self._tid < 0: return -1
|
||
self._running = 1
|
||
return 0
|
||
|
||
def is_alive(self) -> int:
|
||
return self._running
|
||
|
||
def get_tid(self) -> int:
|
||
return self._tid
|
||
|
||
|
||
class Process:
|
||
_pid: int
|
||
_path: [128]char
|
||
|
||
def __init__(self, path: const str):
|
||
self._pid = -1
|
||
i: int = 0
|
||
for ch in path:
|
||
if i >= 127: break
|
||
self._path[i] = ch
|
||
i += 1
|
||
self._path[i] = 0
|
||
|
||
def start(self) -> int:
|
||
self._pid = spawn(&self._path[0], 0)
|
||
return self._pid
|
||
|
||
def start_blocking(self) -> int:
|
||
self._pid = spawn(&self._path[0], 1)
|
||
return self._pid
|
||
|
||
def get_pid(self) -> int:
|
||
return self._pid
|