OS Topic 12 - Memory management Flashcards

1
Q

A modern personal computer’s OS supports multiple processes, each of which demands its own allocation of memory for p________ i___________ and for d__________.

A

program instructions and for data

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

The operating system must manage how memory is allocated among many p_________.

A

processes

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

The part of the operating system responsible for carrying out memory management is the ‘m_________ m___________ m__________’.

A

memory management module

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

There are four important issues that the OS memory management module must deal with;

  1. A____________ memory
  2. R___________
  3. P___________
  4. L_________ memory size
A

allocating memory
relocation
protection
limited memory size

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

Allocating Memory

The memory management module
must manage memory by allocating it among m_________ p___________

A

multiple processes

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

Relocation

The memory management module must be able to relocate programs so they can be loaded wherever there is f_____ s_______ available.

A

free space

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

Protection

The memory management module must enforce the s_____________ of one process’s memory from another.

Why?

A

separation
This is a security risk: malicious software in one process could obtain sensitive data from another process. There is also a risk that a program that contains bugs could inadvertently write to memory belonging to another process.

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

Limited Memory Size

The memory management module must be able to manage more programs than will fit into main memory by using s__________ storage.

A

secondary storage

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

Virtual memory

Memory management module Vs memory management unit.

Match the definitions:

  1. A memory management module is: _____
  2. A memory management unit is: _____

a) A functional block in the processor
b) A software module in the operating
system

A

1b
2a

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

Virtual memory

A Memory Management Unit (MMU) is a h__________ component in a computer’s p_________ that handles the translation of v_________ addresses used by software into p________ addresses in the computer’s memory.

A

hardware component
processor
virtual
physical

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

Virtual memory

When a program is loaded into memory, it uses v_________ addresses, which are addresses that might not directly correspond to the physical location in memory. The MMU steps in and translates these virtual addresses into the actual p_______ addresses in the computer’s memory.

A

virtual
physical

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

Virtual memory

Virtual addresses are used by the program during its e__________, while physical addresses represent the actual locations in the physical memory h__________. The MMU ensures that the correct m_________ between virtual and physical addresses is maintained.

A

execution
hardware
mapping

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

Virtual memory

Systems like this which translate logical addresses used by programs into different physical addresses are called v________ m_________ s________

A

virtual memory systems

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

Recap - Registers

What is a register?
A register is a small, fast storage location within the CPU (Central Processing Unit) that is used to store data t____________ during the execution of a program.

A

temporarily

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

Recap - Registers

Here are three common types of register, there are many more, though.

  1. D_______ R_________
  2. A_________ R_________
  3. P___________ C__________
A
  1. Data Registers
  2. Address Registers
  3. Program Counter (PC)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Recap - Registers

Match the tasks to the correct registers.

a) Keeps track of the address of the next
instruction to be fetched and executed.

b) Used to store data operands for
arithmetic and logic operations.

c) Hold memory addresses or pointers.

  1. Data Registers
  2. Address Registers
  3. Program Counter
A

1b
2c
3a

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

Virtual memory - definition

What is an operand?

An operand is a term used to describe the data on which a mathematical or logical operation is performed on.

e.g. ADD A, B

What are the operands in this code?

A

A, B

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

Virtual Memory

True or false?
A logical address is the same thing as a virtual address.

A

true

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

Virtual Memory

Why use virtual addresses instead of physical addresses?

Virtual memory provides the illusion of a dedicated and contiguous address space for each p___________, while efficiently sharing the physical memory among multiple processes.

A

process

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

Virtual Memory

A processor with two special-purpose registers – a base register and a length register – provides a simple m_______ of implementing a virtual memory system.

A

method

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

Base and length registers

The base register contains the amount to be added to every logical address. If it contains 4000 (to continue the example above), then a logical address of 123 is translated to a physical address of ________

A

4123

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

Base and length registers

When discussing addresses we must note that one address typically corresponds to one b________ of data.

A process may require several a_________ as it may have many bytes of data.

The addressing s_______ of a process is the range of addresses that the process can use.

A

byte
addresses
space

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

Base and length registers

The length register contains the h________ logical address required by the process.

Highest Logical Address: The value stored in the length register represents the highest or maximum logical address that the process may need during its execution.

A

highest

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

Base and length registers

In essence, the length register helps in managing and controlling the addressing space for a particular process.

It could be part of the system’s memory management unit and is used to ensure that the process does not access memory beyond its a___________ range.

A

allocated

25
Q

Base and length registers

What happens if a process tries to access an address higher than its allocated range?

The _ _ _ can detect any attempt to use an address outside this range and generate an invalid address fault.

A

MMU

26
Q

Base and length registers

How is an invalid address fault handled?

This fault is handled by the p________ and o_________ s__________ in the same way as an i__________, so control can be returned to the operating system to deal with the problem.

A

processor
operating system
interrupt

27
Q

Base and length registers

In summary
Each process has its own base and length values which are stored in the p_______ c________ b________. Every time there is a context switch, the operating system has to load values for the new process into the base and length registers.

A

process control block

28
Q

Swapping

Suppose a user starts a new program, but the operating system finds that there is insufficient free memory to load it.

Can the OS just remove the previously running process?

A

No

Just removing the process would be disastrous since data will be lost;

29
Q

Swapping

Swapping refers to the process of moving data between the m____ m______ (RAM) and secondary storage (typically a h____ d____ or SSD).

This is done when the operating system needs to f_____ u_____ space in the RAM for other processes.

A

main memory
a hard disk
free up

30
Q

Paged virtual memory

Current operating systems employ a form of virtual memory s___________ called paged virtual memory

A

system

31
Q

Paged virtual memory

In a paged memory system, memory is treated as being made up of fixed-size pages, a common size being 4 KiB (______ bytes).

A

4096 bytes

32
Q

Paged virtual memory

True or False?
Individual pages can be swapped between main memory and the swap space.

A

True

33
Q

Paged virtual memory

True or false?
Logical memory pages cannot be put into any available physical memory page – they must be contiguous with other pages from the same process.

A

False

Logical memory pages CAN be put into any available physical memory page – not necessarily in order or contiguous with other pages from the same process.

34
Q

Paged virtual memory

How the MMU in a paged system translate logical addresses into corresponding physical addresses? (1)

First, we need to work out how many addresses we have.
If a page can hold 4 KiB, or 4 x 2^10, or 4096 bytes, how many bits will that be, i.e, ones and zeros?

e.g. 1111 0000 (8 bits)

4 x 2^10 = 2^2 x 10^2 = 2^12 bytes

How many bit would we have with 2^12 bytes?

A

12 bits (a.k.a. 12 numbers)

e.g. 1111 1111 1111

35
Q

Paged virtual memory

How the MMU in a paged system translate logical addresses into corresponding physical addresses? (2)

We now know that in binary 4096 bytes can be represented by 12 bits (12 numbers).

What is the range of addresses in hexadecimal (starting at zero) corresponding to a 4 KiB page?

Well, in binary, we would have a range of
0000 0000 0000 - 1111 1111 1111

What would this be in Hex?

A

000 - FFF

36
Q

Paged virtual memory

True or false?
Each 4 KiB page will run from addresses 000 - FFF

A

True

37
Q

Paged virtual memory

True or false?
An example address from page 4, would be
3D49

A

False

It would be 4D49

38
Q

Paged virtual memory

The MMU translates addresses for a w_______ page at a time, so a particular 4 KiB page of logical memory is translated in its entirety to a different 4 KiB page in physical memory.

A

a whole page

39
Q

Paged virtual memory

The last three hexadecimal digits represent the address within the page and remain u___________ when it is translated. These three hexadecimal digits are called the o____.

E.g. Logical address - 3FFF
Physical address - A7FFF

A

unchanged
the offset

40
Q

Paged virtual memory

The operating system keeps track of which logical page is stored in which physical page by means of a p_____ t______.

Each process has its own page table.

A

page table

41
Q

Paged virtual memory

Number of pages = Total size of process
_____________________
page size

How many pages would a 16 KiB process need, if the page size were 4 KiB?

A

4 pages

42
Q

Paged virtual memory

As we know, the OS keeps track of a processes logical and physical address by means of a page table.

Where is the page table stored?

A

In main memory

43
Q

Paged virtual memory

What is the purpose of a Translation Lookaside Buffer (TLB)?

The TLB is a hardware c_____ that stores a s______ of the page table entries. It is a small, high-speed cache located in the _____. When a virtual address needs to be translated to a physical address, the MMU first checks the TLB. If the translation is found in the TLB (a TLB hit), it’s a fast lookup, and the physical address is obtained without accessing the main memory page tables.

So, its purpose is to improve s______/e________.

A

cache
subset
CPU
speed/efficiency

44
Q

Paged virtual memory

True or false?

As with other cache, the number of entries in the TLB is limited, for example to just 64 entries.

A

True

45
Q

Page faults

True or false?

  1. The main memory is RAM.
  2. The main memory is non-volatile
A
  1. True
  2. False
46
Q

Page faults

Consider the situation where some pages in the logical memory of a process are not currently in memory but only on the swap space.

The page table records which pages are currently in p________ main memory. Each entry has a valid/invalid b____ which is set to valid when the page is present and invalid if the page is not present.

A

physical main memory
bit

47
Q

Page faults

When the pages of a process are brought into memory, the corresponding entry in the page table is marked as valid. A page table entry can be marked invalid for one of two reasons:

  1. The page is part of the logical address
    space of the process but it is currently in
    the s______ s_______ rather than main
    memory.
  2. The page may not be in the logical
    address space of the process; for
    example, a b____ may cause a reference
    to an address outside the process’s
    address limit.
A

swap space
bug

48
Q

Page faults

Any memory access through an entry marked invalid in the page table causes a p_____ f_______, which is handled in the same way as an i__________.

A

page fault
interrupt

49
Q

Page faults

What is the first thing an operating system page fault handler will check for?

A

illegal memory access

by checking the address against the limits stored in the process control block.

50
Q

Page faults

If there has been a illegal memory access what will the OS do?

A

terminate the process with an error message

51
Q

Page faults

If the address is a valid logical address, then the reference is to a page that is on the s_____ s__________ but not yet in memory.

In this case, the _______ must bring the page into memory.

A

swap space
OS

52
Q

Page faults

True or false?

The operating system will perform a context switch to allow other processes to continue when it is dealing with a page fault.

A

True

53
Q

Page faults

The time taken to handle a page fault is dominated by the time taken to access s_________ s__________.

A

secondary storage

54
Q

Page faults

True or false
Changing the swap device from a hard disk drive (HDD) to a solid-state drive (SSD) would reduce the time taken to handle page faults.

If true, why?

A

True - because SSDs are faster than HDDs.

55
Q

Page faults

True or false

An OS designer is not responsible for keeping the frequency of page faults very low.

A

False - they must try to do that!

56
Q

Page faults

For a computer user struggling with a slow system, the options are either to run fewer, smaller applications or _________________________________________

A

buy more physical memory

57
Q

Page faults

What does a system thrash mean?

The computer spends all its time dealing with page faults and no useful p________ is made by any application process.

A

progress

58
Q

Page faults

A