Current fibril model can confuse kernel's view on threads
Since the times of HelenOS 0.2.0, the fibril (formerly pseudo threads) scheduling uses a task-global queues for inactive fibrils. Thanks to this arrangement, fibrils can migrate among kernel threads. The problem here is that also kernel threads with userspace context (userspace threads) have some fibril characteristics and can migrate just as any other fibril. This is a potential problem: imagine the userspace context of a kernel thread is migrated to another thread. The migrated thread then calls thread_exit(). From the kernel's point of view, a wrong thread is terminated; its userspace context will however survive and will be migrated to another thread, deepening the confusion. Note that this behaviour also negatively impacts thread cycle accounting.
A possible solution is to turn the global queues into thread-local queues and enable migration only per explicit request. That would demand other changes in userspace thread/fibril cleanup.
Another solution might be to selectively disable migration of thread contexts, i.e. coexistence of the task-global and thread-local fibril queues.