Why is it sometimes necessary to create new worker threads, that execute deferrable work functions, instead of just scheduling it on the default "events/n" kernel worker thread ?
The events worker thread need to multiplex many tasks, so it's not allowed to block it (call schedule() inside single task). However there are many tasks that need to block (wait for disk, network, some device etc.) and there are many functions in kernel that block internally (like semaphores or even memory allocation). Such functions may only be run on behalf of userland inside a syscall or in a dedicated kernel thread.
While it would be theoretically possible to rewrite such code to a long chain of events, it would make it complex and unmaintainable and the overhead of kernel thread is quite small.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With