PrevNEXT

How Operating Systems Work

By: Curt Franklin & Chris Pollette

Memory Storage and Management

IT, Linux specialist
IT specialist Mario Haustein works on a computer with the operating system Linux at the computer center of the Technical University in Chemnitz, Germany, March 8, 2017. Jan Woitas/picture alliance via Getty Images

When an operating system manages the computer's memory, there are two broad tasks to be accomplished:

  1. Each process must have enough memory in which to execute, and it can neither run into the memory space of another process nor be run into by another process.
  2. The different types of memory in the system must be used properly so that each process can run most effectively.

The first task requires the operating system to set up memory boundaries for types of software and for individual applications.

Advertisement

As an example, let's look at an imaginary small system with 1 megabyte (1,000 kilobytes) of RAM. During the boot process, the operating system of our imaginary computer assigns enough memory to meet the needs of the operating system itself. Let's say that the operating system needs 300 kilobytes to run. Now, the operating system goes to the bottom of the pool of RAM and starts building up with the various driver software required to control the hardware subsystems of the computer. In our imaginary computer the drivers take up 200 kilobytes. So, once the operating system is completely loaded, there are 500 kilobytes remaining for application processes.

When applications begin to be loaded into memory, the operating system assigns them an amount of memory. As the next application launches, the operating system takes away some memory from other open applications to make sure the newest application has enough to run. With that ensured, the larger question is what to do if the 500-kilobyte application space is filled.

In most computers, it's possible to add memory beyond the original capacity. For example, you might expand the RAM in your computer from 8 to 16 gigabytes. But most of the information that an application stores in memory is not being used at any given moment. A processor can only access memory one location at a time, so the vast majority of RAM is unused at any moment. The operating system constantly swaps out the unused parts for the parts being used. This gives each process its own space and keeps them from corrupting one another. This technique is called virtual memory management.

Disk storage is only one of the memory types that must be managed by the operating system, and it's also the slowest. Ranked in order of speed, the types of memory in a computer system are:

  • High-speed cache: This is fast, relatively small amounts of memory that are available to the CPU through the fastest connections. Cache controllers predict which pieces of data the CPU will need next and pull it from main memory into high-speed cache to speed up system performance.
  • Main memory: This is the RAM that you see measured in gigabytes when you buy a computer.
  • Secondary memory: This is often a hard drive (HDD) or solid state drive (SSD) inside the computer which serves as virtual RAM under the control of the operating system.

The operating system must balance the needs of the various processes with the availability of the different types of memory, moving data in blocks called pages between available memory as the schedule of processes dictates.

Featured