# Why are the kernel idle threads TCB objects?

**URL:** <https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58>\
**Category:** seL4 kernel\
**Created:** [January 29, 2019, 11:59pm UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58 "2019-01-29T23:59:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kent.mcleod](https://avatars.discourse-cdn.com/v4/letter/k/7ab992/32.png) [@kent.mcleod](https://sel4.discourse.group/u/kent.mcleod)\
**Post date:** [January 29, 2019, 11:59pm UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58/1 "2019-01-29T23:59:44Z")

</div>

What are the reasons for the idle threads using TCB objects when the bookkeeping required for an idle thread is less than a user thread? On some architectures TCBs can be up to 2KiB in size.

---

<div class="post-metadata">

**Author:** ![anna.lyons](https://yyz2.discourse-cdn.com/free1/user_avatar/sel4.discourse.group/anna.lyons/32/4_2.png) [@anna.lyons](https://sel4.discourse.group/u/anna.lyons)\
**Post date:** [January 30, 2019, 8:29pm UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58/2 "2019-01-30T20:29:26Z")

</div>

I once experimented with making the idle thread a TCB like any other, and inserting it into the scheduler at low priority. Maybe that was the thought?

However, the idle thread itself is special, and we barely use any of the fields in the idle thread TCB (basically the state and it’s pointer). Users aren’t provided with a capability to the idle thread TCB so it cannot be invoked.

Changing this would require some changes to the proof to make the idle thread a minimal set of kernel state and not a TCB.

---

<div class="post-metadata">

**Author:** ![gerwin.klein](https://yyz2.discourse-cdn.com/free1/user_avatar/sel4.discourse.group/gerwin.klein/32/46_2.png) [@gerwin.klein](https://sel4.discourse.group/u/gerwin.klein)\
**Post date:** [February 1, 2019, 1:29am UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58/3 "2019-02-01T01:29:19Z")

</div>

Yes, making the idle thread not have a TCB object would cause even more special cases for the idle thread in the proof. The more it can be handled like any other thread the better. The number of idle threads in the system is the number of CPUs. If that is large, we’d expect the overall memory size also to be large.

---

<div class="post-metadata">

**Author:** ![tsewell](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tsewell](https://sel4.discourse.group/u/tsewell)\
**Post date:** [February 6, 2019, 4:55am UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58/4 "2019-02-06T04:55:02Z")

</div>

I recall a former colleague saying that introducing the idle thread was great, because it simplified the interrupt etc exception handling paths. There’s always a TCB available with a register file into which the register state is saved the same way. Of course, this seems to create special cases for the idle thread everywhere else.

---

<div class="post-metadata">

**Author:** ![curtis](https://yyz2.discourse-cdn.com/free1/user_avatar/sel4.discourse.group/curtis/32/12_2.png) [@curtis](https://sel4.discourse.group/u/curtis)\
**Post date:** [February 14, 2019, 11:55pm UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58/5 "2019-02-14T23:55:36Z")

</div>

Doesn’t it scale with the number of domains as well? Or is that something that Qian’s work introduces?

---

<div class="post-metadata">

**Author:** ![anna.lyons](https://yyz2.discourse-cdn.com/free1/user_avatar/sel4.discourse.group/anna.lyons/32/4_2.png) [@anna.lyons](https://sel4.discourse.group/u/anna.lyons)\
**Post date:** [February 18, 2019, 1:12am UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58/6 "2019-02-18T01:12:21Z")

</div>

Yeah, there’s an idle thread per domain per core.

---

<div class="post-metadata">

**Author:** ![nick](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@nick](https://sel4.discourse.group/u/nick)\
**Post date:** [February 27, 2019, 12:05am UTC](https://sel4.discourse.group/t/why-are-the-kernel-idle-threads-tcb-objects/58/7 "2019-02-27T00:05:59Z")

</div>

> [@kent.mcleod](#):
>
> idle threads

We use idle threads as a work around for the scheduler and the IRQ handler.
