@@ -104,14 +104,14 @@ export namespace sched
104104 // called on yield, block, timer or wake up
105105 void schedule ();
106106
107- process_t * create_process (process_t * parent);
107+ std::shared_ptr< process_t > create_process (const std::shared_ptr< process_t > & parent);
108108
109109 // create a new kernel thread under pid 0
110- thread_t * create_kthread (std::uintptr_t ip, std::uintptr_t arg, nice_t nice = default_nice);
110+ std::shared_ptr< thread_t > create_kthread (std::uintptr_t ip, std::uintptr_t arg, nice_t nice = default_nice);
111111
112112 // create a user thread
113- thread_t * create_uthread (
114- process_t * proc, std::uintptr_t ip, std::uintptr_t arg,
113+ std::shared_ptr< thread_t > create_uthread (
114+ const std::shared_ptr< process_t > & proc, std::uintptr_t ip, std::uintptr_t arg,
115115 bool is_trampoline, bool is_clone,
116116 std::uintptr_t stack, nice_t nice = default_nice
117117 );
@@ -120,17 +120,17 @@ export namespace sched
120120 void enqueue_new (thread_t *thread);
121121
122122 // create a new kernel thread and enqueue it
123- thread_t * spawn (std::uintptr_t ip, std::uintptr_t arg = 0 , nice_t nice = default_nice);
123+ std::shared_ptr< thread_t > spawn (std::uintptr_t ip, std::uintptr_t arg = 0 , nice_t nice = default_nice);
124124
125125 template <typename Func>
126- inline thread_t * spawn (Func &&func, std::uintptr_t arg = 0 , nice_t nice = default_nice)
126+ inline std::shared_ptr< thread_t > spawn (Func &&func, std::uintptr_t arg = 0 , nice_t nice = default_nice)
127127 {
128128 return spawn (reinterpret_cast <std::uintptr_t >(func), arg, nice);
129129 }
130130
131131 template <typename Func, typename Arg>
132132 requires (!std::convertible_to<Arg, std::uintptr_t >)
133- inline thread_t * spawn (Func &&func, Arg arg, nice_t nice = default_nice)
133+ inline std::shared_ptr< thread_t > spawn (Func &&func, Arg arg, nice_t nice = default_nice)
134134 {
135135 return spawn (
136136 reinterpret_cast <std::uintptr_t >(func),
@@ -142,6 +142,9 @@ export namespace sched
142142
143143 bool yield ();
144144
145+ void request_kill (thread_t *thread, int exit_code);
146+ void die_if_kill_pending ();
147+
145148 // exit the current thread
146149 // if this is the last thread, process becomes a zombie
147150 [[noreturn]] void thread_exit (int exit_code);
@@ -153,12 +156,12 @@ export namespace sched
153156 // status reported to waitpid will have WIFSIGNALED set
154157 [[noreturn]] void process_exit_signal (int signo, bool core_dumped = false );
155158
156- process_t * get_process (pid_t pid);
157- thread_t * get_thread (pid_t tid);
159+ std::shared_ptr< process_t > get_process (pid_t pid);
160+ std::shared_ptr< thread_t > get_thread (pid_t tid);
158161
159162 std::size_t process_count ();
160163
161- void for_each_process (std::function<bool (process_t * )> func);
164+ void for_each_process (std::function<bool (const std::shared_ptr< process_t > & )> func);
162165
163166 // called from a timer interrupt
164167 void tick (bool from_user);
0 commit comments