recitations

Freezer runqueue

This guide was written by Ryan Wee in Spring 2024. The code snippets and links in this post correspond to Linux v5.10.205.

Introduction

First of all, it is entirely possible (and probable) that there are mistakes in this guide. If so, feel free to contact the TA team.

This guide is meant to complement Mitchell’s guide – it’s a good idea to read both of them. Mitchell’s guide explains what each of the sched_class functions do. The aim of this guide is to provide an event-driven perspective of how these functions are invoked. In particular, how is the freezer runqueue modified in response to different events?

TLDR

When a task’s timeslice is up

When a task voluntarily yields, but is RUNNABLE

In this case, the task wants to be remain on the runqueue. It’s just telling the kernel: “Okay, you can shift me to the back of the runqueue because I’m nice. But feel free to select me again when you want to!”

When a task voluntarily yields, and is not RUNNABLE

In this case, the task wants to be taken off the runqueue. This could be because the task called __wait_event_interruptible(), or sleep(), or anything that basically indicates it wants to suspend its execution for the near future. Another common case would be when the task finishes its execution.