summaryrefslogtreecommitdiff
path: root/Kernel/init.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-01 14:41:49 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-01 14:41:49 +0100
commit3a901ae36d91093b7b6135f5fe05c36ad3ec71b1 (patch)
treed253f646d8b82a4b8f2fccb51928ec3db0452f17 /Kernel/init.cpp
parent52607aa08661c8bcbbb6d51bb8dfce63e68a47cc (diff)
downloadserenity-3a901ae36d91093b7b6135f5fe05c36ad3ec71b1.zip
Way tighter locking in process creation.
We no longer disable interrupts around the whole affair. Since MM manages per-process data structures, this works quite smoothly now. Only procfs had to be tweaked with an InterruptDisabler.
Diffstat (limited to 'Kernel/init.cpp')
-rw-r--r--Kernel/init.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 12ce7eea8d..1c6763d007 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -101,6 +101,25 @@ static void undertaker_main()
}
}
+static void spawn_stress() NORETURN;
+static void spawn_stress()
+{
+ dword lastAlloc = sum_alloc;
+
+ for (unsigned i = 0; i < 100; ++i) {
+ int error;
+ Process::createUserProcess("/bin/id", (uid_t)100, (gid_t)100, (pid_t)0, error, nullptr, tty0);
+ kprintf("malloc stats: alloc:%u free:%u\n", sum_alloc, sum_free);
+ kprintf("delta:%u\n", sum_alloc - lastAlloc);
+ lastAlloc = sum_alloc;
+ sleep(600);
+ }
+ for (;;) {
+ asm volatile("hlt");
+ }
+}
+
+
static void init_stage2() NORETURN;
static void init_stage2()
{
@@ -173,20 +192,6 @@ static void init_stage2()
}
#endif
-#ifdef STRESS_TEST_SPAWNING
- dword lastAlloc = sum_alloc;
-
- for (unsigned i = 0; i < 100; ++i) {
- int error;
- auto* shProcess = Process::createUserProcess("/bin/id", (uid_t)100, (gid_t)100, (pid_t)0, error);
- kprintf("malloc stats: alloc:%u free:%u\n", sum_alloc, sum_free);
- kprintf("sizeof(Process):%u\n", sizeof(Process));
- kprintf("delta:%u\n",sum_alloc - lastAlloc);
- lastAlloc = sum_alloc;
- sleep(600);
- }
-#endif
-
int error;
auto* sh0 = Process::createUserProcess("/bin/sh", (uid_t)100, (gid_t)100, (pid_t)0, error, nullptr, tty0);
#ifdef SPAWN_MULTIPLE_SHELLS
@@ -195,6 +200,10 @@ static void init_stage2()
auto* sh3 = Process::createUserProcess("/bin/sh", (uid_t)100, (gid_t)100, (pid_t)0, error, nullptr, tty3);
#endif
+#ifdef STRESS_TEST_SPAWNING
+ Process::createKernelProcess(spawn_stress, "spawn_stress");
+#endif
+
#if 0
// It would be nice to exit this process, but right now it instantiates all kinds of things.
// At the very least it needs to be made sure those things stick around as appropriate.