+static void
+proc_timer_callback(struct proc_info* proc)
+{
+ proc->timer = NULL;
+ proc->state = PROC_STOPPED;
+}
+
+__DEFINE_LXSYSCALL1(unsigned int, sleep, unsigned int, seconds)
+{
+ // FIXME: sleep的实现或许需要改一下。专门绑一个计时器好像没有必要……
+ if (!seconds) {
+ return 0;
+ }
+
+ if (__current->timer) {
+ return __current->timer->counter / timer_context()->running_frequency;
+ }
+
+ struct lx_timer* timer =
+ timer_run_second(seconds, proc_timer_callback, __current, 0);
+ __current->timer = timer;
+ __current->intr_ctx.registers.eax = seconds;
+ __current->state = PROC_BLOCKED;
+ schedule();
+}
+
+__DEFINE_LXSYSCALL1(void, exit, int, status)
+{
+ terminate_proc(status);
+}
+
+__DEFINE_LXSYSCALL(void, yield)
+{
+ schedule();
+}
+
+pid_t
+_wait(pid_t wpid, int* status, int options);
+
+__DEFINE_LXSYSCALL1(pid_t, wait, int*, status)
+{
+ return _wait(-1, status, 0);
+}
+
+__DEFINE_LXSYSCALL3(pid_t, waitpid, pid_t, pid, int*, status, int, options)
+{
+ return _wait(pid, status, options);
+}
+
+pid_t
+_wait(pid_t wpid, int* status, int options)
+{
+ pid_t cur = __current->pid;
+ int status_flags = 0;
+ struct proc_info *proc, *n;
+ if (llist_empty(&__current->children)) {
+ return -1;
+ }