Joined March 2011
714 Photos and videos
Pinned Tweet
20 May 2021
New kernel post! This time: /proc/*/mem and how it writes to unwritable mem. Key takeaway: By walking page tables in software, the kernel can access userspace mem without directly dereferencing pointers it gets from userspace. (No WP/SMAP bits involved). offlinemark.com/2021/05/12/a…
2
132
479
week 124, streaming kernel dev right now discovered a dead end with my stack guard pages approach last stream, will regroup and decide on a final strategy for handling them this stream see ya 👋 youtube.com/live/AWEvMSTkqEA…
1
6
837
for anyone that didn't know, I also make short form OS development content too lol
1
14
1,193
i'm going viral on some other part of this site lol ty @gxjo_dev for posting and @kneeanderthul for crediting me AMA about building an OS in c for 123 weeks in a row, all live-streamed
Jun 10
while everyone is vibe coding SaaS clones this guy is 119 weeks deep into building an operating system from scratch.
6
4
57
4,798
week 123, streaming kernel dev right now topic: stack guards smart pointers testing the stack guard support we developed last week, and also improving and iterating on the pool smart pointers see ya 👋 youtube.com/live/NPe-uAYn8-M…
1
21
2,569
week 122, streaming kernel dev right now topic: stack guard pages continuing with the custom allocator for task stacks, plus some smart pointer refactors youtube.com/live/YBYhzWc12eE…
5
874
week 121, streaming kernel dev right now continuing with various scheduling/task related development, eg stack guard pages, refining the context switch implementation, etc youtube.com/live/E3dllUoDqso…
1
1
19
1,858
good progress, extracted a generic BitmapAllocator out from my bitmap physical memory allocator, so we can reuse it to build a custom pool allocator for the TaskStacks the custom pool allocator is necessary, because I want to have a fixed pool of stacks for kernel tasks, and unmap all their guard pages up front the standard pool I use stores a freelist in unused objects, which crashes if I unmap the guard page so i'm implementing a custom allocator that stores uses a bitmap instead of a freelist, and stores the metadata out of line
2
253
nsfc programmers
OoOoooO my GOD, YEEEES!!! I've waited for C 26's static reflection to make it into GCC for sooooo long... and here she is: running on a freaking Sega Dreamcast!!! This crazy abomination of a constrained constexpr function template, enum_to_string(), takes the value of an enumeration then reflects back upon its type at compile-time, returning the string identifier name that corresponds to the given value... providing us with a mechanism for automatic stringification of compile-time enumeration values! I'm most excited to explore what static reflection has to offer in C 26 for the sake of auto-generating Lua bindings and wrappers to other languages, reflectively... ...If nothing else, it's totally worth it to master these features to freak out and morally offend my C programmer colleagues. 🤣
11
2,686
Mark retweeted
I'd like programmers to retire the "isn't this just reinventing <thing>?" responses. Nobody has read every Wikipedia article. Nobody agrees on every piece of terminology. Reinvention is a good & necessary thing, because it renews, updates, and clarifies ideas. It's also admirable, because it means that someone discovered something important without it being told to them already. That is a much more valuable trait than memorizing terminology and facts.
63
62
1,026
27,788
week 120, streaming kernel dev right now topic: scheduling / task stacks will continue with either: 1. changing the task register state to be stored on the stack, instead of in the task struct, or 2. continuing with task stacks see ya 👋 youtube.com/live/05EpiLxPhAk…
1
1
23
1,836
instead of storing the task register state in the task struct, I tried storing it on the stack, with a pointer to that stored in the task struct this had the advantage of simplifying the asm context switch routines, making them mostly pushes and pops, which was nice however, it adds some complexity which I don't love. there's now this pointer in the task struct that needs to be set correctly and not null. And it's a little cumbersome to make sure that pointer gets set in the context switch. Doing it all in the task struct was simpler in this regard I'm not sure if the slightly simplified assembly is worth it in the end tbh, given the other complexity introduced
4
516
week 116, streaming kernel dev right now topic: kernel threads today i'll be debugging a boot loop issue that appeared after I cranked up the number of tasks on the system from 4 to 4000. in general working more on scheduling and refining it see ya 👋 youtube.com/live/UrVVFu81YWg…
3
5
39
3,327
ok. the problem was caused by 1. having guard pages 2. unmapping them all from the VA space all on init 3. managing them all the task stacks in an ETL pool the ETL pool uses a freelist internally to implement the allocator and when an object in the pool is unused, it superimposes a metadata struct at the start of the object with eg the freelist pointers this breaks if I unmap the guard page, since the metadata is no longer writeup too bad, looks like I'll have to find another way to allocate task stacks (i've been trying to avoid writing a general purpose kernel heap)
368
week 115, streaming kernel dev right now topic: kernel threads continue with properly cleaning up task stacks at the end of a task lifetime, probably implementing some kind of deferred task cleanup see ya 👋 youtube.com/live/eFS0hbpKexc…
1
1
18
1,330
deferred task cleanup implemented! after the next task is chosen, I switch stacks, run a cleanup routing on the new tasks's stack, then enter the next task
2
387
week 114, streaming kernel dev right now topic: scheduling working more on scheduler stuff -> idle task, scheduling policies, mapping the stack, etc see ya 👋 youtube.com/live/ap76LbNwWgM…
6
754
week 113, streaming kernel dev right now topic: kernel threads continuing with scheduling/kernel threads, working on thread exit, an idle task, and properly mapping stacks instead of using the physmap see ya 👋 youtube.com/live/DM13pqlDenI…
1
3
25
2,348
got it working, tasks can yield and exit. idle task ensures there's always something runnable I still don't have a virtual memory allocator, so I punted on the "properly map stacks instead of using physmap" by statically allocating a stack frame directly in the Task struct lol
4
433
week 112, streaming kernel dev right now topic: scheduling continue on scheduling, refactoring the yield path with an idea to remove the global scratch buffer. and then creating an api to allow tasks to exit see ya 👋 youtube.com/live/Jtw6fD75uGY…
1
5
43
3,617
got kernel thread exiting working, including a little landing pad if a task accidentally returns without calling the exit API! I prepare the stack such that there is a RIP value at the top that points to a landing pad function that calls the exit API (this is doable since tasks aren't called into, but rather push ret'd into)
304