Memory Management (PPT 5 - 6) Flashcards Preview

Architecture and Operating Systems > Memory Management (PPT 5 - 6) > Flashcards

Flashcards in Memory Management (PPT 5 - 6) Deck (34)
Loading flashcards...
1
Q

Can we extend main memory using a hard disk?

A

Yes, this is virtual memory. However, it is still slow.

2
Q

What governs memory address and register usage?

A

The program code being run.

3
Q

Why use memory management?

A

The Operating System needs to allocate memory as efficiently as possible and keep track of those sector of memory which are free and which are in use (And what process is using each section)

4
Q

What is memory management?

A

Management is needed to handle memory resources of a computer as efficiently as possible. It is partly static and partly dynamic and is governed by the OS, with hardware support from the processors.

5
Q

What are the aims of memory management?

A

Primary function is to bring processes and data from secondary storage to main memory ready for execution. The following aims are desirable:
Protection
Sharing
Relocation

6
Q

What is Sharing?

A

In a multi user and multi program environment, the same data can be used multiple times. It is therefore memory efficient if only one copy is stored and shared between processes.

7
Q

What is Protection?

A

We need to prevent unauthorised programs accessing areas of memory allocated to other processes. This means the OS must protect processes (“Fence off” memory areas)

8
Q

What is Relocation?

A

A process must be capable of being loaded into any part of the address space. This means data pointers and branch pointers within the program can be accessed in a relative way, using their base address (start address of the program), and a logical way, which is relative to the base address. This is done by the compiler

9
Q

How is memory allocated?

A

When a process is loaded, it must be placed into memory as efficiently as possible. If insufficient free memory is available, we must remove another process to free memory.

10
Q

What are the four partitioning schemes?

A
  • Fixed Size Partition
  • Variable Size Partition
  • Segmentation
  • Paging
11
Q

What are Fixed Size Partitions?

A

When a process is loaded, it is placed into the smallest free partition which can fit all of it. If no segments are free, a process is then unloaded

12
Q

What are the key points of Fixed Sized Partitions?

A
  • There is always memory wasted at the end of a segment
  • When a process is unloaded, the whole segment is freed
  • Data structures can grow but there is a limit
13
Q

What are Variable Size Partitions?

A

When a process is loaded in, it is placed in the first available partition which can fit all of it. If no segments are free, memory is unloaded.

14
Q

What are the key points of Variable Size Partitions?

A
  • No memory is wasted when loading processes

- As time goes on, memory becomes fragmented. Possible to defragment but this takes time.

15
Q

What is Segmentation?

A

When a process is loaded in, it is itself segmented in order to fit into all available memory spaces

16
Q

What are the key points of Segmentation?

A
  • Fragmentation is eliminated but the process itself becomes fragmented (not an issue if we keep track of fragments)
  • Data structures that grow and shrink can be handled more easily
  • Different protection properties can be given to each segment
  • Hardware support in current CPUs
17
Q

What is Paging?

A

When a process is loaded in, it is divided into relatively small fixed-size pages. Memory is divided into frames of the same size. Process pages are loaded into the minimum required frames

18
Q

What are the key points of Paging?

A
  • At most, a fraction of one frame is wasted when a process is loaded
  • When a process is unloaded the space is freed in page sized sections, so is readily re used by the next process
  • The frames used by a process need be contiguous in memory, so relocation is easy
  • There is some fragmentation but it does not get worse over time.
19
Q

What is a major benefit of using Pages?

A

We only need to load the page actually being processed into memory. This means that:

  • We can start running a process as soon as the first page is loaded.
  • We can have pages from many processes inn main memory, maximising the multi processing capabilities
  • We can run processes that are actually larger than main memory
20
Q

Is there a clear better Partitioning scheme?

A

No, each partitioning scheme has its advantages and disadvantages. Operating systems generally only use one scheme.

21
Q

What is MMU?

A

Memory Management Unit
There must be a map between the address requested by the CPU and the actual page which stores that data. The MMU uses a page translation table to information about memory contents, such as which frames are used and which pages they contain.

22
Q

What does the mapping process do?

A

The mapping process converts the logical address from the CPU into a physical address by looking up the page translation table

23
Q

What is the difference between large and small pages?

A

Large pages contain more addresses within them but there is usually less of them. While smaller pages contain fewer addresses but there are more of them

24
Q

How do you find the physical address of a page?

A

You first take the address offset which is where the memory address is in relation to the start of the page. You then take the page number and replace this with the frame which it is contained within. these two parts create the physical address

25
Q

What is the Physical Address of the Logical Address $00015F08 when it is contained within frame 004E and the page size is 64K?

A

Physical Address is $004E5F08

26
Q

How are Translation Tables stored?

A

Tables are stored in main memory. Most CPUs use a Address Translation Cache which caches translated addresses so they can be supplied faster

27
Q

What is a Single Level Translation Table?

A

The entire table is stored in main memory , including invalid entries which cause page faults. These tables can be very large unless large pages are used.

28
Q

How can we reduce the size of Translation Tables?

A

We can reduce the size by using multi level translation tables. This means having multiple tables which only contain a few frames within them. The logical address will contain level zero page and level one page along with the offset

29
Q

What are the advantages and disadvantages of Multi level Translation?

A

Adv: Only a complete level 0 table has to be in main memory(level 1 tables can be virtual memory), so tables take up less main memory space (despite bing larger than single level tables)

Disadv:Longer table walks required by MMU as it has to search down two levels to find final page address (This will be rare due to ATC)

30
Q

What is virtual memory?

A

Virtual memory is when pages which are inactive are temporarily put on a hard disk. In theory, it will be 50:50 real to virtual memory. In practice, however, the code actually being used must be in the real part.

31
Q

What happens when a requested page’s physical address shows it is in virtual memory?

A

A page or hard fault occurs meaning the page must be brought from disk, likely causing a swap, then a read cycle can be performed. This is demand paging

32
Q

Why do we want to avoid page faults?

A

Page faults take a long time to process as the hard disk is slow and if the program keeps jumping from one page to another with only one page in memory, then we can get an I/O “thrashing” situation. Locality of reference means that this problem won’t happen often

33
Q

What are the benefits of virtual memory?

A

If an I/O operation is blocking the progress of a process, the OS can give other processes more time on the CPU by sending the process to virtual memory/

34
Q

What are the ways we can deal with replacing a page if there are no free pages?

A

Similar to cache, we can use First in First out, Least Recently Used or Least Frequently Used. The same principles apply.