aboutsummaryrefslogtreecommitdiff
path: root/src/tcb.c
AgeCommit message (Collapse)Author
2024-08-30improvements to shared memory handlingKimplul
+ Now each shared region is reference counter (technically each region is refernce counted, private regions just have a count of 1). Also, syscalls that touch the TLB get flushed, but should probably look into where else this flushing might be needed.
2024-08-30fix a couple memory issuesKimplul
+ get_mem_node() clears out the memory so we don't accidentally read stale flags + Thread creation simplified a bit, each thread references itself and data freeing is based on when the reference count reaches zero.
2024-08-26fix memory leaks destroying threadsKimplul
2024-08-26make sys_create() better + testKimplul
2024-08-26improve killing processes/threads, testKimplul
+ Remove sys_kill() as we should be using a two-stage process where a thread is first orphaned by sys_detach(), and then the thread itself calls sys_exit() after it has done all necessary cleanup in init.
2024-07-14expose max number of concurrent threads to usersKimplul
+ Can be used to build fast hashmaps to speed up ipc
2024-07-14add more checks to getting tcbKimplul
2024-07-09allow mapping null pageKimplul
+ User has to 'free' the 0 page before it becomes accessible to mapping. Probably worth noting that this is likely VERY niche and mainly concerns stuff like certain kinds of emulators that I'm still eons from implementing, but still. Unbacked pages can also be useful for some kinds of notifications, like 'if someone writes to this page, please report it to me with this ID' or whatever, I remember seeing some discussion about it somewhere but that's also not really relevant for the moment. Most significantly, at least with the current design, after the null page is freed it becomes available for use to regular req_mem() calls, so users should probably using locks around memory requests. That's probably a good idea anyway as internally the kernal has to lock the virtual memory, and without a scheduler it might cause threads to spin for a while in the kernel which is rather bad.
2024-07-08fix LLVMKimplul
+ Anything extern is right out as LLVM doesn't produce correct code for them. Maybe if I added some extra attributes but I'm skeptical. Replaced with static variables and getters/setters. + Inline ASM is apparently a bit buggy, so use an assembly stub when jumping to init. + Minimize work done in main() to minimize chance of LLVM doing something silly. Still not 100% certain that I shouldn't just write the main() as an assembly stub in arch/riscv64 to be absolutely sure everything works as intended. + Make .kernel.start section SHF_ALLOC, otherwise lld complains about pc-relative addressing Probably some other stuff as well that I'm forgetting right now. But at least with LLVM14 LTO seems to work, which is pretty cool?
2024-07-07simplify assertionsKimplul
+ No real point having multiple different levels of assertions, just say you assert something and be done with it
2024-07-07smp now seems to workKimplul
+ Had some minor issues with a wraparound of size_t that effectively meant that some regions were allocated twice. Also, booting should be a bit more reliable now, turned out that the previous iteration of the booting was just accidentally working due to the kernel being placed 'close enough' in RAM to where it was linked to. Fixed by allocating a vmem of O1 that maps the kernel to a 2MiB boundary at boot, pretty nifty.
2024-07-06core bringup + various warningsKimplul
+ dbg_fdt() is apparently broken, possibly due to UB or something, but it causes some issues with optimizations enabled. Remove it temporarily
2024-07-06adjust stack handlingKimplul
2024-07-06pretty massive virtual memory rewriteKimplul
+ The system is now a bit simpler and hopefully easier to understand, while also extending the shared memory to be 1:N, where there is one owner who may become a zombie while waiting for the N to die.
2024-07-05allow booting with Qemu's -kernel flag directlyKimplul
+ Took some fairly significant changes, for one the kernel is no longer relocated at the start of a boot, instead it sits wherever the user decides the kernel should sit. Similarly, the initial kernel stack and page table are stored within the binary, slightly bloating the size but making it much safer to boot since there's really no chance of us overwriting the fdt or initrd in memory.
2024-07-04generalize orphantsKimplul
+ Allow threads to make themselves become orphants
2024-07-04add note about orphaning running threadsKimplul
2024-07-04add zombie and orphan threadsKimplul
+ Should write this down somewhere but the idea is that when a process gets killed, it frees all the memory it can, making all threads within that process orphans. Orphaned threads are assigned to the init process, which will generally call exit() on each one. Zombie threads are threads that own some bit of shared data, and whose reference count is above zero. They may not be swapped to or called, even though they take up space in thread map and reserve their thread ID.
2024-05-24rename common to srcKimplul
+ I keep starting to type src and wondering why autocomplete won't work, I guess src is just uncounciously a better name