1. 9
  1.  

  2. 1

    I don’t fully understand this.

    What exactly does “thread context” mean in this case?

    1. 3

      Specifically not interrupt context. Meaning execution can be suspended and resumed while waiting for other things to complete.

      1. 1

        Thanks for replying.

        When are we in kernel-space but not because of an interrupt?

        Why wouldn’t one want a “thread waiting around all the time”? Why is using a “job” resource better than a thread?

        1. 3

          You can be running in the kernel to handle a system call from userspace.

          Classically, you would have lots of kernel threads. I’ve got a reaper, a swapper, an acpi thread, a usb thread, another usb thread, a sensors, a i915, a i915-hangcheck, and so on. But it’s a bit of clutter.

          More pragmatically, the guts of all these threads tends to be very similar, a short loop sleeping and processing a list when something appears. Easier to just use a common API.

          As a particular use case, in OpenBSD, you push the volume down key, so we want to lower the volume. But you don’t know the state of the audio system. And it’s bad to block and wait until audio is ready to adjust. So you add a task, which will run a little bit later, but allows the keyboard code to keep running.

          1. 1

            Ok. I think I understand this now.

            So the ACPI handler or whatever recognises the media key, and kicks off the job.

            The scheduler schedules the threadpool, and noting it’s got a ready job runs it. Timer ISR fires and schedular treats it just like any other (kernel) thread.

            It’s “better” than a thread because it doesn’t show up in the process list, and you have less code (since you don’t have to emulate unix inside the unix kernel).

            That about right?

            1. 0

              “More pragmatically, the guts of all these threads tends to be very similar, a short loop sleeping and processing a list when something appears. Easier to just use a common API.”

              Yall are inching closer and closer to microkernel architecture. They just do that with everything in the system. :) Plus some optimizations…

              1. 2

                Though hopefully not all of it in ring 0.

                1. 1

                  That’s exactly what Apple did. ;)

        2. 0

          In the scope of a thread