Page 1 of 1

Kernel maintenance thread

Posted: Sat Mar 31, 2012 10:02 am
by invalid
Hello!

In my other topic (http://forum.osdev.org/viewtopic.php?f=1&t=25084 - thanks to all participants!) it appears to be a consensus that the kernel usually needs some maintenance thread.

I can see two reasons for spawning such thread:
  • some work may be postponed to be run in background (e.g. cleaning lists of unused entries)
  • implementation details create artifacts, which are hard to override (e.g. problem with releasing current task's stack)
And now I wonder: what are the jobs that you decided/were forced to defer to the maintenance thread in your kernel?

Re: Kernel maintenance thread

Posted: Sat Mar 31, 2012 10:35 am
by brain
How about garbage collection for interpreted languages ;-) I intend to add this as soon as its needed, right now I just garbage collect in the main thread at regular intervals between lines of interpreted code.

Re: Kernel maintenance thread

Posted: Sat Mar 31, 2012 10:43 am
by bluemoon
You may also do some kind of benchmark, adaptive adjustment of parameters based on collected data and runs in background.
For example, cache expiry/invalidation to reclaim memory.

Basically, IMO, kthread are workaround for monolith kernel which those functionality are likewise implemented in servers for micro kernel.

Re: Kernel maintenance thread

Posted: Sat Mar 31, 2012 12:59 pm
by egos
There are some jobs that are executing within same or several kernel-owned threads:
  • zeroing pages;
  • thread destruction;
  • executing HLT;
  • etc.