mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
Kernel: Allocate version string in the Process::initialize() method
Instead of allocating a KString on each uname syscall, just allocate during boot so we never have to worry about heap allocation in that syscall.
This commit is contained in:
parent
d8b514873f
commit
58b509584a
2 changed files with 9 additions and 2 deletions
|
@ -40,6 +40,7 @@
|
|||
#include <Kernel/Tasks/Thread.h>
|
||||
#include <Kernel/Tasks/ThreadTracer.h>
|
||||
#include <Kernel/Time/TimerQueue.h>
|
||||
#include <Kernel/Version.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -47,6 +48,7 @@ static void create_signal_trampoline();
|
|||
|
||||
extern ProcessID g_init_pid;
|
||||
extern bool g_in_system_shutdown;
|
||||
extern KString* g_version_string;
|
||||
|
||||
RecursiveSpinlock<LockRank::None> g_profiling_lock {};
|
||||
static Atomic<pid_t> next_pid;
|
||||
|
@ -162,6 +164,9 @@ UNMAP_AFTER_INIT void Process::initialize()
|
|||
// Note: This is called before scheduling is initialized, and before APs are booted.
|
||||
// So we can "safely" bypass the lock here.
|
||||
reinterpret_cast<FixedStringBuffer<UTSNAME_ENTRY_LEN - 1>&>(hostname()).store_characters("courage"sv);
|
||||
// NOTE: Just allocate the kernel version string here so we never have to worry
|
||||
// about OOM conditions in the uname syscall.
|
||||
g_version_string = MUST(KString::formatted("{}.{}-dev", SERENITY_MAJOR_REVISION, SERENITY_MINOR_REVISION)).leak_ptr();
|
||||
|
||||
create_signal_trampoline();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue