blob: cc1d205941f00b952eec14de81fa2307c2cbafdc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* -------------------------------------------
Copyright ZKA Technologies.
------------------------------------------- */
#include <NewKit/Utils.hxx>
#include <KernelKit/CodeMgr.hxx>
#include <KernelKit/UserProcessScheduler.hxx>
namespace Kernel
{
/// @brief Executes a new process from a function. Kernel code only.
/// @note This sets up a new stack, anything on the main function that calls the Kernel will not be accessible.
/// @param main the start of the process.
/// @return if the process was started or not.
Bool sched_execute_thread(MainKind main, const Char* process_name) noexcept
{
if (!main)
return No;
UserProcess proc;
proc.SetImageStart(reinterpret_cast<VoidPtr>(main));
proc.Kind = UserProcess::eExecutableKind;
proc.StackSize = kib_cast(32);
rt_set_memory(proc.Name, 0, kProcessLen);
rt_copy_memory((VoidPtr)process_name, proc.Name, rt_string_len(process_name));
return UserProcessScheduler::The().Add(proc) > 0;
}
} // namespace Kernel
|