ArticleslgStudy

computer science

Run queue

Run queue 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 Run queue rather than just read about it. In short: In modern computers many processes run at once. Active processes are placed in an array called a run queue, or runqueue.

Key takeaways

  • Run queue 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 Run queue to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Run queue from memory before moving on to harder problems.

Reference excerpt

In modern computers many processes run at once. Active processes are placed in an array called a run queue, or runqueue. The run queue may contain priority values for each process, which will be used by the scheduler to determine which process to run next. To ensure each program has a fair share of resources, each one is run for some time period (quantum) before it is paused and placed back into the run queue. When a program is stopped to let another run, the program with the highest priority in the run queue is then allowed to execute. Processes are also removed from the run queue when they ask to sleep, are waiting on a resource to become available, or have been terminated. In the Linux operating system (prior to kernel 2.6.23), each CPU in the system is given a run queue, which maintains both an active and expired array of processes. Each array contains 140 (one for each priority level) pointers to doubly linked lists, which in turn reference all processes with the given priority. The scheduler selects the next process from the active array with highest priority. When a process' quantum expires, it is placed into the expired array with some priority. When the active array contains no more processes, the scheduler swaps the active and expired arrays, hence the name O(1) scheduler. In UNIX or Linux, the sar command is used to check the run queue. The vmstat UNIX or Linux command can also be used to determine the number of processes that are queued to run or waiting to run. These appear in the 'r' column. Example:

$ vmstat procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 2 0 0 4579152 324416 4619528 0 0 402 236 3357 15 20 2 78 0 0

There are two models for Run queues: one that assigns a Run Queue to each physical processor, and the other has only one Run Queue in the system

See also Completely Fair Scheduler, the scheduling algorithm used by Linux since kernel 2.6.23

References Tanenbaum AS (2008) Modern Operating Systems, 3rd ed., p. 753-4. Pearson Education, Inc. ISBN 0-13-600663-9 Silberschatz, Galvin, Gange (2012) Operating System Concepts, 9th ed.. Wiley, ISBN 978-1-118-55963-5

Worked examples

Example 1 — a first encounter with Run queue

Start with the simplest possible case. Write down what Run queue 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 Run queue 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 Run queue 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 Run queue

In research
Run queue 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 Run queue 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
Run queue is common in secondary-school and first-year university syllabi. It links to neighbouring topics Linux kernel, Scheduling (computing), so understanding it makes those chapters shorter.
In everyday life
Look for Run queue 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 “Run queue” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Run queue in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Run queue 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 Run queue out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Run queue in simple terms?

In modern computers many processes run at once. Active processes are placed in an array called a run queue, or runqueue.

Why does Run queue 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 Run queue?

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 Run queue.

Tags

  • Linux kernel
  • Scheduling (computing)

Keep exploring