Memory Management Flashcards

1
Q

What is the CPU Instruction Cycle?

A
  1. Fetch: Getting the instruction from memory.
  2. Decode: Understanding what the instruction does.
  3. Execute: Performing the instruction’s operation.
  4. Store: Writing back results to memory if needed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are registers?

A

Can be accessed within a single CPU cycle (extremely fast)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is the main memory accessed?

A

Accessed over a memory bus; typically slower than registers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is cache memory?

A

Fast memory between the CPU and main memory to reduce access
times. It stores frequently used data and instructions to avoid slow
main memory access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is the Memory Hierarchy accessed?

A

*Helps balance speed, size, and cost, typically organized as:
* Registers > Cache > Main Memory (RAM) > Secondary Storage (Disk)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

L1 Cache

A

Fastest and smallest, located inside the CPU core.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

L2 Cache

A

Larger but slower, still on the CPU chip.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

L3 Cache

A

Shared among cores, significantly larger but
slower than L1 and L2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Memory Isolation

A

Ensures that a process cannot access memory outside its
allocated space, protecting the OS and other processes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Security Enhancement

A

Prevents malicious or faulty programs from causing memory
corruption.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Dynamic Relocation

A

Allows the OS to move processes in memory by updating only
the base register, without altering the program code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is address binding?

A

Address binding transforms logical addresses (generated
by programs) into physical addresses (used by hardware).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a logical address?

A

A logical address (also known as a virtual address) is an
abstract address that a process uses to access memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a physical address?

A

A physical address refers to the actual location in the
physical memory (RAM).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What 3 times can address binding of instructions and data to memory addresses happen?

A
  • Compile time
  • Load time
  • Execution time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Load Time Binding

A
  • Used when the load address is not known at compile time.
  • The compiler generates relocatable code, meaning addresses are
    relative to a base address.
  • The loader calculates the absolute addresses when the program is
    loaded into memory.
  • Flexibility: The program can be loaded at different memory
    locations without recompiling
17
Q

Execution Time Binding

A
  • The most dynamic form of address binding.
  • Binding occurs when instructions are executed.
  • Requires special hardware support, typically through the MMU.
  • Allows processes to move freely between memory locations during
    execution, as logical addresses are dynamically translated to
    physical addresses.
  • Essential for modern operating systems that use paging or
    segmentation.
18
Q

How is Logical Address (Virtual Address) created?

A
  • Generated by the CPU during program execution
  • The address seen by the program
19
Q

Physical Address

A
  • The actual address in the memory unit
  • The address used by the memory hardware to access memory
    cells
20
Q

Static Binding

A
  • Address binding is completed before execution.
  • Occurs at compile time or load time.
  • Suitable for simple systems with predictable memory usage.
21
Q

Dynamic Binding

A
  • Binding occurs during execution.
  • Allows for dynamic memory allocation, swapping, and relocation.
  • Enables virtual memory systems, allowing processes to use more
    memory than physically available
22
Q

What is dynamic loading?

A

Dynamic loading is a technique where a program loads a module or
routine into memory only when it is needed.

  • Modules can include libraries, functions, or data segments that are
    not immediately required when the program starts.
  • Memory Efficiency
  • Faster Start-Up
23
Q

Dynamic Linking

A
  • When a program is written, it typically contains reference to
    external libraries
  • A program that has these libraries incorporated into its binary at
    compile time is said to be statically linked
  • Dynamic linking postpones the linking until runtime
  • Reduces the memory footprint of running programs.
  • Allows multiple processes to share the same code, particularly
    with shared libraries
24
Q

Standard Swapping

A
  • A process may be swapped out of memory to a backing store, then
    brought back when needed
  • Allows total memory used by processes to exceed physical memory size
  • Often combined with priority-based scheduling
  • Low priority process more likely to be swapped out
  • Greatly increases the cost of context switching
  • Reading/writing secondary storage is relatively slow
  • Time to swap is proportional to memory usage of process
25
Q

Contiguous Allocation

A
  • A process is allocated a single contiguous block of memory in main
    memory.
  • The entire memory space required by the process must fit into one
    continuous segment.
26
Q

Multi-Partition Allocation

A
  • Main memory is divided into multiple fixed or variable-sized
    partitions, and each partition can hold a single process.
  • Fixed vs. Variable Partitions:
  • Fixed-Size Partitions: Equal-sized chunks (partitions) in advance.
  • Variable-Sized Partitions: Partitions are created dynamically based on
    process size.
  • Unused memory referred to as holes
27
Q

Fragmentation

A

Two types of fragmentation
* External fragmentation – when memory is available in holes, but
many small holes rather than one contiguous block
* Can be reduced by Compaction
* Shuffle memory contents to place all free memory together in one large
block
* Compaction is possible only if relocation is dynamic, and is done at
execution time
* I/O Problem
* Internal fragmentation – occurs if processes are allocated slightly
more than requested (e.g. so that a small hole is left)

28
Q

Dynamic Storage-Allocation Problem

A
  • Different approaches to allocating memory n from a list of holes
  • First fit:
  • Allocate the first hole that is big enough
  • Best fit:
  • Allocate the smallest hole that is big enough; must search entire list,
    unless ordered by size
  • Produces the smallest leftover hole
  • Worst fit:
  • Allocate the largest hole; must also search entire list
  • Produces the largest leftover hole
  • First-fit and best-fit better than worst-fit in terms of speed and
    storage utilisation
29
Q

Segmentation

A
  • Memory-management scheme that supports user view of memory
  • Segmentation involves recognising that a program is a collection of
    segments, such as:
  • Main program
  • Function
  • Method
  • Stack
  • Variables
  • Symbol table
  • These do not need to be contiguous in memory
30
Q

Paging – Basic Method

A
  • Physical address space of a process can be noncontiguous;
    process is allocated physical memory whenever the latter is
    available
  • One way of dealing with external fragmentation
  • Physical memory divided into fixed-size blocks called frames
  • Logical memory is divided into blocks of the same size, called
    pages
  • Program of N pages neds to find N free frames
  • Page table translates logical to physical addresses
  • Still have internal fragmentation
31
Q

Address Translation Scheme pages

A
  • Address generated by CPU is divided into:
  • Page number (p) – used as an index into a page table which contains base
    address of each page in physical memory
  • Page offset (d) – combined with base address to define the physical
    memory address that is sent to the memory unit