Final Exam Part 1 Flashcards

1
Q

True/False: Only one thread can be in monitor at a time

A

True

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

Difference between p() and wait()?

A

P only blocks if c < 0, wait() ALWAYS blocks

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

Difference between v() and signal()?

A

The v() signal is NEVER lost, where signal() may be lost if the queue is empty.

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

What is the output of the following code if T1 goes first? if T2 goes first?

procudere procA{
b.signal
a.wait
}

procedure procB{
b.wait
a.signal
}

T1
while(1){
AB.procA
print(a)
}

T2
while(1){
AB.procB
print(b)

A

T1 first: deadlock

T2 first: [ab]*

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

A file is to be shared among different processes, each of which has a unique number. The file can be accessed simultaneously by several processes, subject to the following constraint: The sum of all unique numbers associated with all the processes currently accessing the file must be less than n. Write a monitor to coordinate access to the file.

A

Monitor resourceAllocate
{
int sum;
condition c;

void	AccessFile(int	num)	
{	
	 while(sum+num>=n)	
	 {	
	 	 c.wait();	
	 }	
	 sum+=num;	}	
void		FinishAccessing(int	num)	
{	
	 sum=	sum-n;	
	 c.signal();	
}	
void	init()	
{	
	 sum=0;	
}	
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define paging

A

A technique to implement virtual memory

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

The key issue in virtual memory is WHEN to bind variables to a location. What are three different ways of doing this? Which one is used today?

A
  1. At compile time. Compiler determines where to place program in MM.
    Disadvantages: program has to be recompiled every time it is run.
  2. At load time.
    Disadvantage: Program has to remain in the same location, and the entirety of the program needs to be loaded in MM.
  3. At runtime. This one is used regularly.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the four different memory management techniques?

A
  1. Contiguous
  2. Paging
  3. Segmentation
  4. Segmentation + Paging
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Address binding is done by the _____.

A

MMU (Memory management unit)

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

How is a virtual address converted to a physical address in the contiguous memory management scheme?

A
  1. CPU generates virtual address.
  2. There is a MBR and an MLR in the MMU. The physical address created is the virtual address + MBR so long as it is <= the MLR.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What would the physical address be if a CPU generated a virtual address of 5, and the MBR and MLR had values of 270 and 595 respectively?

A

275

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

Consider MM with holes as shown below:

Hole 1- 68K
Hole 2- 96K
Hole 3- 78K
Hole 4- 25K
Hole 5- 80K

If two processes wanted to get into main memory with sizes of 75K and 25K respectively, which hole would each process go into? Answer the question with all four contiguous memory policies.

A

First Fit: Hole 2, Hole 1
Next Fit: Hole 2, Hole 3
Best Fit: Hole 3, Hole 4
Worst Fit: Hole 2, Hole 5

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

What are the two major disadvantages of the contiguous memory management scheme?

A
  1. Complete program must be loaded into MM.

2. Memory fragmentation.

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

Define the two different types of fragmentation.

A

Internal: Hole within program

External Fragmentation: Holes between programs

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

Out of the four contiguous memory policies, which leads to the most fragmentation? Which type of fragmentation is it? Why?

A

Best fit. Consider the following scenario:

Hole: 25K
Process 23K

Process will give entire 25K to process since the 2K will not be of any use elsewhere. This means that internal fragmentation is occurring because the process has 2K worth of space it isn’t using.

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

True/False: In general, 1/2 of MM lost due to fragmentation.

A

False: approximately 1/3

17
Q

What is the solution to fragmentation?

A

Compaction: move programs to one end so there is a large hole at the other end.

18
Q

What five things must be true in the paging memory management scheme?

A
  1. Program is divided into pages.
  2. Every page is of the same size.
  3. VM is divided into pages.
  4. PM is divided into frames.
  5. Page size = Frame size
19
Q

True/False: Size of VM must be equal to size of PM in memory management scheme.

A

False: Does not matter as long as page and frame size are equal.

20
Q

Why does page size need to equal frame size?

A

So the number of words are the same in pages and frames.

21
Q

The page table is stored in the TLB normally rather than MM. Why is this the case?

A
  1. HW is fast.
  2. MM has to be accessed twice for every LA -> PA if page table is stored in MM.
    a) Access Page table to get Frame #
    b) Access Physical address.
22
Q

Typically, how much internal fragmentation occurs in the paging memory management scheme? How much external fragmentation?

A

Internal: approximately 1/2 page per program.
External: None, page size = frame size.

23
Q

Suppose the following:

Page size: 4 words
Virtual Memory: 64 words
Physical Memory: 1024 words

What is the frame size? number of frames? number of pages?

Give the page # and word # for the following LAs: 9, 43, 40.

A

Frame size: 4 words
number of pages: 16
number of frames: 256

VA 9: Page 2 word 1
VA 43: Page 10 word 3
VA 40 Page 10 word 0

24
Q

What are the five parts of a page table entry?

A
  1. Page replacement policy bits.
  2. Protection bits
  3. Dirty bit: whether page has been WRITTEN to.
  4. Residency bit: whether page is loaded in MM.
  5. Frame number
25
Q

True/False: The OS will throw out pages with a dirty bit set.

A

False, the dirty bit of 1 means the page has been written to and the OS will assume that the page is in use.

26
Q

Given 16 frames in MM, and that the residency bit is immediately to the left of the frame#, which address would result in a page fault?
439, 611, 606, 693.

A

611

27
Q

Depict a step by step process of how contents are gotten from a logical address in the paging memory scheme.

A
  1. Convert logical address to binary.
  2. Find page and word number
  3. Index into page + PTBR and get contents.
  4. Convert contents from number 3 into binary.
  5. Check if the page is loaded into MM.
  6. Get frame #.
  7. Append word number from step 2 to frame # in step 6.
  8. Get contents with physical address obtained in step 7.
28
Q

What is the major disadvantage of the paging memory management scheme?

A

Page faults are really high.

29
Q

Define the segmentation memory management scheme.

A

Program is divided into segments, not pages. Each segment is a logical entity, and the entire segment into MM. A physical address is computed as the segment base + word # as long as it is <= the segment bound.

30
Q

What are the advantages and disadvantages of the segmentation memory management scheme?

A

Advantage: Lower page faults.
Disadvantage: segments different sizes, external fragmentation occurs.

31
Q

Define the segmentation + paging scheme.

A

Program is divided into segments AND pages. All pages of a segment must be loaded into MM. There is one segment table per process, 1 page table per segment all stored on the TLB.

32
Q

What is the LA made up of in the segmentation + paging scheme? the PA?

A

LA: Seg# + page# + word#
PA: Frame# + word#

33
Q

How much fragmentation occurs in the segmentation + paging scheme? What types?

A

External Fragmentation: 0

Internal Fragmentation: 1/2 page per segment.

34
Q

What happens when the residency bit is 0? (more detailed than just page fault occurs…)

A
  1. Page fault occurs.
  2. Program is blocked.
  3. OS finds a frame for the page and loads from disk using a page replacement algorithm.
  4. Program goes from blocked to ready.
35
Q

What is the formula for page access time?

A

memory access time + (fault rate) * disk access time

36
Q

Assume TLB access time is zero. What is the page table entry access time?

A

(page table fault rate) * memory access time