ArticleslgStudy

computer science

Brain Fuck Scheduler

Brain Fuck Scheduler is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Brain Fuck Scheduler rather than just read about it. In short: The Brain Fuck Scheduler (BFS) is a process scheduler designed for the Linux kernel in August 2009 based on earliest eligible virtual deadline first scheduling (EEVDF), as an alternative to the Completely Fair Scheduler (CFS) and the O(1) scheduler. BFS was created by Con Kolivas.

Brain Fuck Scheduler — main illustration
Brain Fuck Scheduler — illustration

Key takeaways

  • Brain Fuck Scheduler belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Brain Fuck Scheduler to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Brain Fuck Scheduler from memory before moving on to harder problems.

Reference excerpt

The Brain Fuck Scheduler (BFS) is a process scheduler designed for the Linux kernel in August 2009 based on earliest eligible virtual deadline first scheduling (EEVDF), as an alternative to the Completely Fair Scheduler (CFS) and the O(1) scheduler. BFS was created by Con Kolivas. The objective of BFS, compared to other schedulers, is to provide a scheduler with a simpler algorithm, that does not require adjustment of heuristics or tuning parameters to tailor performance to a specific type of computational workload. Kolivas asserted that these tunable parameters were difficult for the average user to understand, especially in terms of interactions of multiple parameters with each other, and claimed that the use of such tuning parameters could often result in improved performance in a specific targeted type of computation, at the cost of worse performance in the general case. BFS has been reported to improve responsiveness on Linux desktop computers with fewer than 16 cores. Shortly following its introduction, the new scheduler made headlines within the Linux community, appearing on Slashdot, with reviews in Linux Magazine and Linux Pro Magazine. Although there have been varied reviews of improved performance and responsiveness, Con Kolivas did not intend for BFS to be integrated into the mainline kernel.

Theoretical design and efficiency In 2009, BFS was introduced and had originally used a doubly linked list data structure, but the data structure is treated like a queue. Task insertion is ⁠O(1)⁠. Task search for next task to execute is ⁠O(n)⁠ worst case. It uses a single global run queue which all CPUs use. Tasks with higher scheduling priorities get executed first. Tasks are ordered (or distributed) and chosen based on the virtual deadline formula in all policies except for the realtime and Isochronous priority classes. The execution behavior is still a weighted variation of the Round-Robin Scheduler especially when tasks have the same priority below the Isochronous policy. The user tuneable round robin interval (time slice) is 6 milliseconds by default which was chosen as the minimal jitter just below detectable by humans. Kolivas claimed that anything below the 6 ms was pointless and anything above 300 ms for the round robin timeslice is fruitless in terms of throughput. This important tuneable can tailor the round robin scheduler as a trade off between throughput and latency. All tasks get the same time slice with the exception of realtime FIFO which is assumed to have infinite time slice. Kolivas explained the reason why he choose to go with the doubly linked list mono-runqueue than the multi-runqueue (round robin) priority array per CPU that was used in his RDSL scheduler was to put to ease fairness among the multiple CPU scenario and remove complexity that each runqueue in a multi-runqueue scenario had to maintain its own latencies and [task] fairness. He claimed that deterministic latencies was guaranteed with BFS in his later iteration of MuQSS. He also recognized possible lock contention problem (related to the altering, removal, creation of task node data) with increasing CPUs and the overhead of ⁠O(log⁡n)⁠ next task for execution lookup. MuQSS tried to resolve those problems. Kolivas later changed the design to a skip list in the v0.480 release of BFS in 2016. This time this altered the efficiency of the scheduler. He noted ⁠O(log⁡n)⁠ task insertion, ⁠O(1)⁠ task lookup; ⁠O(k)⁠, with ⁠k≤16⁠, for task removal.

Virtual deadline The virtual deadline formula is a future deadline time that is the scaled round robin timeslice based on the nice level offset by the current time (in niffy units or nanosecond jiffies, an internal kernel time counter). The virtual deadline only suggests the order but does not guarantee that a task will run exactly on the future scheduled niffy. First a prio ratios lookup table is created. It is based on a recursive sequence. It increases 10% each nice level. It follows a parabolic pattern if graphed, and the niced tasks are distributed as a moving squared function from 0 to 39 (corresponding from highest to lowest nice priority) as the domain and 128 to 5089 as the range. The moving part comes from the t variable in the virtual deadline formula that Kolivas hinted.

g(0) = 128 g(i) = INT( g(i-1)*11/10 )

The task's nice-to-index mapping function f(n) is mapped from nice −20...19 to index 0...39 to be used as the input to the prio ratio lookup table. This mapping function is the TASK_USER_PRIO() macro in sched.h in the kernel header. The internal kernel implementation slightly differs with range between 100 and 140 static priority but users will see it as −20...19 nice.

The virtual deadline is based on this exact formula:

T = 6 N = 1<<20 d(n,t) = t + g(f(n)) * T * (N/128) Alternatively,

where d(n,t) is the virtual deadline in u64 integer nanoseconds as a function of nice n and t which is the current time in niffies, g(i) is the prio ratio table lookup as a function of index, f(n) is the task's nice-to-index mapping function, T is the round robin timeslice in milliseconds, N is a constant of 1 millisecond in terms of nanoseconds as a latency reducing approximation of the conversion factor of 109ns103ms but Kolivas uses a base 2 constant N with approximately that scale. Smaller values of d mean that the virtual deadline is earlier corresponding to negative nice values. Larger values of d indicate the virtual deadline is pushed back later corresponding to positive nice values. It uses this formula whenever the timeslice expires. 128 in base 2 corresponds to 100 in base 10 and possibly a "pseudo 100". 115 in base 2 corresponds to 90 in base 10. Kolivas uses 128 for "fast shifts", as in division is right shift base 2.

Scheduling policies BFS uses scheduling policies to determine how much of the CPU tasks may use. BFS uses 4 scheduling tiers (called scheduling policies or scheduling classes) ordered from best to worst which determines how tasks are selected with the ones on top being executed first. Each task has a special value called a prio. In the v0.462 edition (used in the -ck 4.0 kernel patchset), there are total of 103 "priority queues" (a.k.a. prio) or allowed values that it can take. No actual special data structure was used as the priority queue but only the doubly linked list runqueue itself. The lower prio value means it is more important and gets executed first.

… excerpt ends here. Continue reading the full article.

Illustrations

Brain Fuck Scheduler: The location of process schedulers in a simplified structure of the Linux kernel
The location of process schedulers in a simplified structure of the Linux kernel

Worked examples

Example 1 — a first encounter with Brain Fuck Scheduler

Start with the simplest possible case. Write down what Brain Fuck Scheduler claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Brain Fuck Scheduler before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Brain Fuck Scheduler ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Brain Fuck Scheduler

In research
Brain Fuck Scheduler appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Brain Fuck Scheduler in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Brain Fuck Scheduler is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free software programmed in C, Linux kernel process schedulers, Software using the GNU General Public License, so understanding it makes those chapters shorter.
In everyday life
Look for Brain Fuck Scheduler outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Brain Fuck Scheduler” →

How to study Brain Fuck Scheduler in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Brain Fuck Scheduler means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Brain Fuck Scheduler out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Brain Fuck Scheduler in simple terms?

The Brain Fuck Scheduler (BFS) is a process scheduler designed for the Linux kernel in August 2009 based on earliest eligible virtual deadline first scheduling (EEVDF), as an alternative to the Completely Fair Scheduler (CFS) and the O(1) scheduler. BFS was created by Con Kolivas.

Why does Brain Fuck Scheduler matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Brain Fuck Scheduler?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Brain Fuck Scheduler.

Tags

  • Free software programmed in C
  • Linux kernel process schedulers
  • Software using the GNU General Public License

Keep exploring