3
Storage Devices & Compression
Part I
Ch.3: Storage Devices & Compression Eng. Omar El Safty
1. Primary Memory
Definition/Main Feature:
Main memory inside the computer that is directly accessible by the CPU.
2. Secondary Storage
Definition/Features:
Non-volatile storage that is not directly accessed by the CPU.
Purpose of secondary storage:
• For permanent/non-volatile storage of data
• To store data that is not currently required by the CPU
• To store data to transfer it to another computer
• To allow software to be installed on the computer
• For the creation of virtual memory
Technologies of secondary storage:
• Magnetic
• Optical
• Solid-state
47
Ch.3: Storage Devices & Compression Eng. Omar El Safty
Differences between Primary Memory and Secondary Storage:
Primary Memory Secondary Storage
Directly accessible by CPU Not directly accessible by CPU
Faster access speed Slower access speed
Tends to have greater storage
Stores startup instructions and can hold data Permanently stores files and software
and instructions whilst processed
Can be volatile or non-volatile Non-volatile
2.1 Magnetic storage
Features/Characteristics of magnetic storage:
• Data is stored in the form of magnetic dots
• Consists of several platters where magnetic dots are
stored
• Magnetic dots are stored on the platters in sectors and
tracks
• Data is read, written, or erased as the magnetic dots pass
under read/write heads
Examples of magnetic storage devices:
• Hard disk drive (HDD)
• Portable hard disk drive
• Magnetic tape drive
48
Ch.3: Storage Devices & Compression Eng. Omar El Safty
How is data read from magnetic devices?
1 Data, in the form of magnetic dots, is stored on the surface of
multiple platters in sectors and tracks
2 Platters are spun at a high speed
3 Several electromagnetic read/write heads move quickly back and
forth to access all tracks and sectors
4 Data is read as dots pass under electromagnetic read/write heads
How is data written on magnetic devices?
1 Data, in the form of magnetic dots, is stored on the surface of multiple platters in
sectors and tracks
2 Platters are spun at a high speed
3 Several electromagnetic read/write heads move quickly back and forth to access all
tracks and sectors
4 The electromagnetic read/write heads apply a suitable magnetic field to control the
magnetic dots
2.2 Optical storage
Features/Characteristics of optical storage:
• Data is represented on disks as pits and land
• The optical device shines a (red/blue) laser on the disk
• An arm is used to move the optical device across the disk
Examples of optical storage:
• CD
• DVD
• Blu-ray disc
KEY TERMS
Pit – An indentation on the surface of an optical disk used to represent data.
Land – The raised surface between two pits.
49
Ch.3: Storage Devices & Compression Eng. Omar El Safty
How to write/record data on an optical storage device?
1 The disk is spun
2 A (red/blue) laser beam is shone onto the surface of the disk
3 An arm moves the laser across the surface of the disk
4 The laser burns pits onto the surface of the disk
5 Both pits and lands represent the binary two values 1 and 0
How to read data from an optical storage device?
1 The disk is spun
2 A (red/blue) laser beam is shone onto the surface of the disk
3 An arm moves the laser across the surface of the disk
4 The laser is used to read the pits and lands on the surface of the disk
5 The reflected light from the laser shining on the disk is captured by a sensor
2.3 Solid-state storage
Features/Characteristics of solid-state storage:
• Uses NAND/NOR chips are used to store data
• Made of transistors that are laid out in a grid
• Transistors are used as control gates and floating gates to control the flow of
electrons
Examples of solid-state storage devices:
• Solid-state drive (SSD)
• Portable SSD
• SD Card
• USB Flash Memory
• RAM
How data is stored on solid-state devices:
1 NAND/NOR chips are used that made of transistors
2 Data is stored by flashing it onto the chips
3 The flow of electrons is controlled using transistors/gates
4 Data is stored sequentially as 0s and 1s inside the transistors
50
Ch.3: Storage Devices & Compression Eng. Omar El Safty
How data is read from solid-state devices:
1 NAND/NOR chips are used that made of transistors
2 Data is stored by flashing it onto the chips
3 The flow of electrons is controlled using transistors/gates
4 Data is stored sequentially as 0s and 1s inside the transistors
5 Data is read sequentially by retrieving the binary values of transistors
Advantages of using solid-state technology compared to magnetic technology:
• Faster data access speed
• No moving parts, so more durable
• Less power consumption
• They run much cooler
• They occupy less physical space
• They are lighter (making them more suitable for a portable computer)
• They run quieter
• Not affected by magnetic fields
Disadvantages of using solid-state technology compared to magnetic technology:
• More expensive than magnetic devices for the same amount of storage
• Solid-state devices have lower longevity for read/write operations
The following table summarizes the comparison between different types of storage:
Magnetic Storage Optical Storage Solid-State Storage
Storage Capacity Highest Low High
Data Access Speed Fast Slow Fastest
Moving parts Has moving parts Has moving parts No moving parts
Durability Vulnerable to shocks More durable/robust More durable/robust than
and magnetic fields than magnetic storage optical and magnetic storage
Price Per GB Low Low High
Special Great longevity Not compatible with all • Runs cool
Characteristics devices • Low power consumption
• Runs quietly
51
Ch.3: Storage Devices & Compression Eng. Omar El Safty
3. Cloud Storage
Definition:
• Online storage platform
• Data is stored in a remote physical location ..
• .. using hundreds of interlinked data servers
Advantages of using cloud storage compared to storing data locally:
• Data is accessible at any time, from any device, anywhere in the world, provided
internet access is available
• More available storage space
• Storage capacity can be increased without adding additional physical devices
• Automatic backups can be made
• Users only pay for the storage they use
• No need to carry any storage device, so data will not be lost if the storage device is
lost/stolen
Disadvantages of using cloud storage compared to storing data locally:
• Users may lose access to data if internet connection is lost/not available
• Users must have a reliable internet connection to store data
• Cloud storage could incur an ongoing cost
• Reliant on the cloud provider to maintain the hardware
• Loss of control over the storage of data (as storage is controlled by the cloud provider)
• May be less secure (as multiple copies of data are stored for a long period of time)
52
3
Storage Devices & Compression
Part II
Ch.3: Storage Devices & Compression Eng. Omar El Safty
4. File Compression
Effect of compression:
It reduces the file size.
Reasons to compress a file:
• To save storage space
• To make it quicker to transmit
• To make it small enough to attach to an email
• To reduce the bandwidth needed to transmit
4.1 Lossless compression
Definition:
• Method of compression that loses no data in the process
• Used when it is essential that no data is lost during the compression process, for
example:
- Code
- Text file
- Database file
IMPORTANT
Lossless compression can be used on any file type.
53
Ch.3: Storage Devices & Compression Eng. Omar El Safty
4.1.1 Run-length encoding (RLE)
Definition:
• The repeated patterns of characters/pixels/samples are identified ..
• .. then encoded into two values:
1 The number of identical characters in the run (run count)
2 The value of the pattern (run value)
Example:
Consider the following:
000001111222333333444444444
It would be encoded to:
5-0, 4-1, 3-2, 6-3, 9-4
4.1.2 Data Dictionary
Definition:
• The repeated characters/pixels/samples are identified..
• .. then indexed (put in a table)
• .. and then replaced by their index
• The number of occurrences is stored in the table
• The position of repeated characters/pixels/samples in the file is stored in the table
Example:
Consider the following text:
THIS SECTION SHOWS YOU HOW THIS WOULD WORK
Data dictionary:
1= THIS, 2=HOW, 3=OU
The data is encoded to:
1 SECTION S2S Y3 2 1 W3LD WORK
54
Ch.3: Storage Devices & Compression Eng. Omar El Safty
4.2 Lossy compression
Definition:
• Method of compression where redundant details are permanently removed from the
file without significantly affecting the quality of the file
• Used when there is no requirement for the files to be the same as the original file, for
example:
- Images
- Audio files
- Video files
IMPORTANT
Lossy compression reduces the file size more than lossless compression.
Lossy compression lowers the quality of image/sound/video files but NOT significantly.
Advantages of compressing a file using lossy compression compared to lossless
compression:
• Requires less storage space on the computer
• The file is transmitted quicker over the internet
• Less bandwidth is required to send the file over the internet
How to compress an image file using lossy compression:
• A compression algorithm is used..
• ..where redundant details are permanently removed
• Colour depth can be reduced
• Image resolution can be reduced
How to compress a sound file using lossy compression:
• A compression algorithm is used..
• ..where redundant details are permanently removed
• Sampling rate can be reduced
• Sampling resolution can be reduced
• Unnecessary sounds can be discarded (such as removing sounds human ear can’t hear)
55