[SOLVED] Internal Kernel Pseudo-Garbage Collection
Posted: Wed Sep 03, 2014 10:06 pm
Hi! Sorry if this is not gramatically correct, I'm not a native English speaker.
I have a little theorical question. I would want to implement a kernel garbage collection system. Please read-on because the title looks a little newbie I know.
Let's say I have a function that uses A LOT of memory allocation, say for example the VFS Path Divisor. I don't want to spend too much time (less in the VFS and Kernel Library Utilities) comparing hash tables and converting Virtual to Physical Memory inside KFree(), so I decided to do a pseudo-garbage collection system.
You would call a MMGC(void*) function, which would append the address, with some other info like Virtual or Physical, to a constant and premade Stream (I have already implemented a high-level stream manipulation system), then return. The Garbage Collector would be a Kernel-Side process which uses its timeslice only, and only for highly-optimized memory freeing from the stream. If the GC finds that the stream is now empty, it calls the process manager and yields its timeslice inmediately.
And for more optimization, when calling MMGC() and the stream is full, the current process yields its timeslice inmediately to the GC. (There's nowhere to dump the stream when full).
I would want to know if this approach is okay. I think it wouldn't cause a large overhead if the kernel is compiled with a good-sized stream, 2KB for example.
I have a little theorical question. I would want to implement a kernel garbage collection system. Please read-on because the title looks a little newbie I know.
Let's say I have a function that uses A LOT of memory allocation, say for example the VFS Path Divisor. I don't want to spend too much time (less in the VFS and Kernel Library Utilities) comparing hash tables and converting Virtual to Physical Memory inside KFree(), so I decided to do a pseudo-garbage collection system.
You would call a MMGC(void*) function, which would append the address, with some other info like Virtual or Physical, to a constant and premade Stream (I have already implemented a high-level stream manipulation system), then return. The Garbage Collector would be a Kernel-Side process which uses its timeslice only, and only for highly-optimized memory freeing from the stream. If the GC finds that the stream is now empty, it calls the process manager and yields its timeslice inmediately.
And for more optimization, when calling MMGC() and the stream is full, the current process yields its timeslice inmediately to the GC. (There's nowhere to dump the stream when full).
I would want to know if this approach is okay. I think it wouldn't cause a large overhead if the kernel is compiled with a good-sized stream, 2KB for example.