user@system - Terminal
// kernel.c
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main() {
pid_t pid = fork();
if (pid == 0) {
execve("/bin/ls", NULL, NULL);
} else {
wait(&status);
}
}
user@system:~$ gcc -o kernel kernel.c -lpthread
Compilation successful.
user@system:~$ ./kernel
Process 1234 created
Fork successful: PID 1235
Child process executing /bin/ls...
Desktop Documents Downloads kernel kernel.c
Parent process waiting...
Child process exited with status 0
user@system:~$ ps aux | grep kernel
root 1234 0.1 0.2 4512 2048 ? S 12:34 0:01 ./kernel
user 1235 0.0 0.1 2048 1024 ? Z 12:34 0:00 [kernel] <defunct>
user@system:~$ strace -p 1234
read(3, "Hello World\\n", 12) = 12
write(1, "Hello World\\n", 12) = 12
fork() = 1235
execve("/bin/ls", ["/bin/ls"], envp) = 0
wait4(1235, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 1235
exit_group(0) = ?
+++ exited with 0 +++
user@system:~$ cat /proc/1234/maps
08048000-08049000 r-xp 00000000 08:01 12345 /home/user/kernel
08049000-0804a000 rw-p 00001000 08:01 12345 /home/user/kernel
bfffe000-c0000000 rw-p 00000000 00:00 0 [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
user@system:~$
← Back to Blog

Operating Systems

Distributed Computing

Operating systems, distributed computing, and system architecture

System Architecture

Kernel Design Patterns

16 min read

Modern approaches to operating system kernel architecture.

2024-01-13

Distributed Consensus Algorithms

20 min read

Raft, PBFT, and other consensus mechanisms in distributed systems.

2024-01-07

Memory Management Strategies

14 min read

Advanced memory management techniques in modern operating systems.

2024-01-02