• Foundation
  • About 13 min
  • 5 practice questions

Processes, memory and virtual memory

Explain a process, multithreading, and how virtual memory extends RAM using the disk.

If something looks wrong, please tell us.

Behind the scenes, the OS juggles many running programs and a limited amount of RAM. Three terms explain most of it: process, thread and virtual memory.

Process and thread

A program is a file of instructions sitting on a disk. When it runs, it becomes a process. A process can contain smaller units called threads; a browser may use one thread to load a page and another to play a video. Using many threads is multithreading.

CPU scheduling

The CPU can do one thing at a time per core, so the OS gives each process short turns, called time slices. Switching so fast makes it look as if everything runs together.

Virtual memory

If RAM fills up, the OS can use part of the hard disk as extra space for data that is not needed right now. This is virtual memory. It lets bigger programs run but is slower than real RAM, so too much of it makes the computer sluggish.

Deadlock

A deadlock happens when two processes each hold something the other needs and both wait forever. For example, process A holds the printer and needs the scanner, while process B holds the scanner and needs the printer.

Worked examples

Example 1. A computer has 4 GB of RAM and a program needs 5 GB. How can it still run? The OS uses virtual memory, placing part of the data on the disk.

Example 2. Three processes get a time slice of 10 milliseconds each in turn. How long before the first process gets its next turn? The other two take 2 x 10 = 20 ms, so the first waits 20 ms.

Program on disk, process when running. Virtual memory = disk space used like extra RAM.

— Remember

Key takeaways

  • Running programs are processes; they may contain threads.
  • Time slices give the illusion of doing everything at once.
  • Virtual memory extends RAM using the disk but is slower.

Check your understanding

  1. 1. A program that is running is called a

    1. Driver
    2. Folder
    3. File extension
    4. Process
    Show answer

    Answer: D. A program is a file on disk; when it runs it becomes a process.

  2. 2. A browser uses one part to load a page and another to play a video at the same time. These smaller units are

    1. Drivers
    2. Folders
    3. Threads
    4. Time slices
    Show answer

    Answer: C. A process can contain threads; using many threads is multithreading.

  3. 3. What is virtual memory?

    1. Part of the hard disk used as extra space when RAM fills up
    2. Memory inside the monitor
    3. Extra RAM chips added to the computer
    4. A copy of the OS kept in ROM
    Show answer

    Answer: A. Virtual memory uses disk space for data not needed right now, so bigger programs can run.

  4. 4. Why does heavy use of virtual memory make a computer sluggish?

    1. The disk is much slower than RAM
    2. It deletes running programs
    3. The disk is faster than RAM
    4. It switches off the CPU
    Show answer

    Answer: A. Disks are much slower than RAM chips, so relying on virtual memory slows the computer.

  5. 5. Process A holds the printer and needs the scanner; process B holds the scanner and needs the printer. Both wait forever. This is

    1. Virtual memory
    2. Deadlock
    3. Booting
    4. Multithreading
    Show answer

    Answer: B. Each process holds what the other needs, so both wait forever: a deadlock.

Sign in to keep track of the lessons you finish.

Next lesson → Booting and the user interface

Privacy · Terms · Refunds · Delivery