20 + 21 Flashcards

1
Q

What does memory management involve? What is the memory management unit?

A

The memory management unit is responsible for accessing main memory. Memory management deals with how to get processes into main memory and how it is organised?

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

What is address binding?

A

The process where symbols are converted to addresses. This can occur at compile time(can be absolute code if it is known where the process will reside in memory or relocatable code if this is not known.), link time(when linking separate modules)., load time, run time

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

What is dynamic linking and static linking? Which is better?

A

When a source program is compiled, code for functions provided by the language need to be incorporated. In static linking this is done before the program is executed. In dynamic linking it is only done at run-time(stub containing pointer is initialised when ran). Dynamic linking saves memory, load time, and makes updating libraries easier.

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

What are the pros and cons of the main methods for allocating contiguous memory space for a process image?

A

First-fit: take first free block that is big enough, this is quick but unlikely to be optimal.
Best-fit:Find free block that leaves smallest leftover, have to search whole set every time and end up creating lots of small holes.
Worst-fit: Find free block with most space left, still have to check every hole, no small holes, but may be harder to fit large processes.
All suffer from internal and external fragmentation.

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

What is external fragmentation? What about internal fragmentation

A

Enough memory in total, but no individual block small enough to accommodate process.
Internal fragmentation is when the allocated block is larger than the process image but the leftover is too small to be useful.

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

What is a logical and physical address? How do they work?

A

A logical address is mapped to a physical address(the one actually sent to memory unit) at run-time.
A logical address space of a process runs from 0 to the processes memory limit, the physical address space runs from 0 to the size of main memory.
This is mapped by the memory management unit (adding a number N to logical address, N is held in a relocation register).

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

What is paging?

A

A noncontiguous allocation method, in this a process’ logical address space is broken into fixed-size units called pages, main memory is broken into units of the same size, called frames. The logical addresses generated by the CPU contain a page number and an offset, a page table details which frame a page is stored in.

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

Why do page tables typically have an invalid/valid bit?

A

Page tables typically have more entries then a process has pages, the valid/invalid bit can be set to invalid for out-of-range memory references.

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

What are some key points on paging?

A

external fragmentation:none
internal fragmentation: average of half a page per process.
Page size: small, but want disk IO and housekeeping to still be low.
One page table per process.
OS keeps track of process’ page table via PCB.

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

How are page tables normally stored?

A

Keep a cache of recently used page table entries in associative registers(parallel access), store rest in main memory.

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

What is a segmentation allocation scheme?

A

Allow processes to partition their own address space.

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

What is swapping? Why is it good?

A

We can swap processes in and out of main memory in sync with CPU scheduling, allowing more processes to multitask.

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

What is partially loading processes? Why?

A

Don’t fully load the process into memory, use a dynamic loading/linking system to load a routine/function when it is called. This saves memory, increases possible multitasking and makes swapping processes in and out of memory during multitasking easier.

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

What is virtual memory?

A

Automates the loading of processes as they execute. Memory manager maps logical addresses to physical addresses and also loads physical pages into main memory from backing store.

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

What is demand paging?

A

do lazy swapping: only load page into memory once referenced by CPU. Often the invalid/valid bit is used to indicate if a page has been loaded.

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

What is a page fault?

A

Accessing an invalid page results in a page fault, the operating system then determines if it occured because of a valid memory access to an unavailable page or due to invalid access. If invalid memory access, terminate. Else find free frame in main memory, read page from disk to free frame, modify page table appropriately and restart instruction. We can tell if a memory access if valid? use mmap to set up legal virtual memory areas.

17
Q

What is the effective access time

A

(1-probability of page fault) * memory access time + probability of page fault * page fault time.

18
Q

What is the difference in time between a page fault and memory access?

A

1*10^6

19
Q

What are the main page replacement algorithms and what are the pros and cons?

A

FIFO: first in first out, simple but maybe the first page is referenced often. Can also have Belady’s anomaly, page faults increase with more frames in memory.
Optimal: replace page that won’t be used for longest time, algorithm is optimal but can’t realistically be done.
Least recently used: Replace page that has not been used for longest time, optimal if we look backwards in time. but time consuming to keep record of.

20
Q

How do we keep track of the least recently used page?

A

Last time used fiel for each entry in page table or, stack of page numbers, move page to top when used, or, associate reference bit with each page, or, associate several reference bits with each page. Use subsequent bits to store the value of a page’s reference bit at a given moment.

21
Q

What is thrashing? Why can multiprogramming be bad for this?

A

If a process does not have enough frames page faults will occur, with the replaced page being needed shortly after. If a process is spending more time paging then executing than it is thrashing. The CPU can become idle because of this, increasing multiprogramming, and therefore increasing thrashing.

22
Q

What is the locality model? What is the working set?

A

It is typically possible to identify groups of pages which are actively used
together. The working set is an approximation of this, define a parameter which represents the working set window, the set of pages referenced from this is the working set. Allocate each process enough frames to store its current working set.

23
Q

What are pure demand paging and prepaging?

A

pure demand paging: no process’ pages loaded until referenced.
Prepaging: When a process is suspended, we remember its current working set.
When restarted we bring all its working set pages back into memory straight away.