Computer Memory, Multiprogramming, and Data Representation
Explore computer memory architecture, data representation in binary format, and the relationship between memory and multiprogramming. This tutorial explains different memory types, addressing modes, and how available memory impacts the concurrent execution of multiple programs.
Computer Memory and Multiprogramming
What is Computer Memory?
Computer memory is a collection of data stored in binary format (0s and 1s). Different types of memory exist, each serving different purposes. Memory is essential for storing both programs and data. Storage devices (like hard drives and SSDs) provide persistent storage, while RAM (Random Access Memory) provides temporary storage for actively running programs and data.
How Data is Stored
Computers store information in binary form. Every piece of data (numbers, text, instructions) is converted into a binary representation before being stored in memory. For example, the integer value 10 would be stored as its binary equivalent (1010).
Example: Storing an Integer
Consider the C statement: int α = 10;
. In a 32-bit system, an integer is typically 16 bits (2 bytes). Each bit in memory holds a 0 or a 1. For a *signed* integer, the most significant bit represents the sign (0 for positive, 1 for negative). The range for a signed 16-bit integer is -32,768 to +32,767. Using an *unsigned* integer would extend this range to 0 to 65,535.
The Need for Multiprogramming
The CPU directly accesses main memory, cache, and registers. Programs run in main memory. The amount of main memory significantly affects multiprogramming (running multiple programs concurrently). More main memory means the CPU can load more programs at once, improving CPU utilization.
Illustrative Example: Multiprogramming and CPU Utilization
Let's illustrate the impact of memory size on CPU utilization:
Scenario 1: Limited Memory
- Process Size = 4 MB
- Main Memory Size = 4 MB
- I/O time = P (70%)
- CPU utilization = 1 - P = 1 - 0.7 = 0.3 or 30%
Scenario 2: Larger Memory
- Process Size = 4 MB
- Main Memory Size = 8 MB (Two processes can now fit)
- I/O time per process = P (70%)
- CPU utilization = 1 - P2 = 1 - 0.72 = 1 - 0.49 = 0.51 or 51%
Increasing memory increases CPU utilization because more processes can be loaded simultaneously, reducing idle time while waiting for I/O.