Term Test 3
操作系统quiz代写 Question 1 1 pts Virtual memory needs hardware support. True False Question 2 1 pts The main reason to have a multi-level page table is to speed
Question 1 1 pts
Virtual memory needs hardware support.
- True
- False
Question 2 1 pts
The main reason to have a multi-level page table is to speed up address translation.
- True
- False
Question 3 1 pts 操作系统quiz代写
When a new process is created via fork, they share the same page table until one of them writes to a page. This is known as Copy on Write.
- True
- False
Question 4 1 pts
A page that has just been brought into physical memory from the swap should have its dirty bit set.
- True
- False
Question 5 4 pts 操作系统quiz代写
(Recall: 2^5 = 32, 2^6 = 64, 2^7 = 128, 2^8 = 256, 2^9=512, 2^10 = 1024, 2^11 = 2048, 2^12 = 4096)
Consider the following (very small) page-based virtual memory structure for with a linear page table.
- The virtual address space size is 2048 bytes
- The physical memory space is 16 KiB
- Page size is 256 bytes
The page table format:
- The left-most bit is the valid bit
- If the page table entry is valid then the rest of the entry is the physical frame number
Page Table:
0 | 0x8000001d |
1 | 0x00000000 |
2 | 0x8000002f |
3 | 0x00000000 |
4 | 0x8000001f |
5 | 0x00000000 |
6 | 0x80000002 |
7 | 0x8000001c |
Given the following virtual addresses, write “invalid” if the page table entry is not valid, and write the full physical address that the virtual address corresponds to if the page table entry is valid. Write your physical address in hexadecimal notation with NO leading 0’s.
Question 6 5 pts 操作系统quiz代写
The table below represents physical memory with a set of 4 physical frames. The second row shows the virtual page number currently stored in the frame, and the third row shows the current state of the reference bit. The next line shows that the clock hand is pointing to frame 1.
Frame number | 0 | 1 | 2 | 3 |
Page number | 3 | 15 | 9 | 6 |
Ref bit | 0 | 1 | 0 | 1 |
Clock ptr = 0
Show which pages are stored in the frames, the values of their reference bits, and thelocation of the clock pointer after the clock algorithm is run on the following page references.
7, 6, 9, 20
NOTE:
Part 2 of this question will be completed on MarkUs. All of the information below will be available on MarkUs.
To support curbside pickup for a major retailer, an app has been developed so that customers can wait in the vicinity until an agent is ready to serve them.
A person arriving in the vicinity will click a button on the app, and will wait until the app returns with an agent number. The person then goes to the booth with the correct agent number on it to be served. When the person leaves, the agent lets the app know that this agent is available.
Assume that loading the value of a variable is atomic. In other words, you are guaranteed to load a valid value, not some in-between state between two valid values.
For the solution to be correct, it must satisfy three criteria: 操作系统quiz代写
1) An agent serves at most one person at a time
2) The count of the number of people being served at any point in time is accurate
3) If an agent is available, then a person calling find_agent should be able to get a counter number.
The app has 2 functions: find_agent() and ready() . The find_agent() function is invoked in a separate thread for each customer. The ready() function is invoked in a separate thread for each agent.
Two variables and one constant control the state:
available[i] is set to true if agent number i is available.
num_people is a global variable that counts the total number of people being
served at a time.
N is maximum number of agents and is constant
// Called by a customer thread to get the booth number for an available agent int find_agent() { int i; while(1) { for(i = 0; i < N; i++) { if(available[i] == true) { available[i] = false; num_people += 1; return i; } } } } // Called by an agent thread who passes in their agent number void ready(int agent_num) { available[i] = true; num_people -= 1; }
Question 7 0.5 pts 操作系统quiz代写
There is a race condition in accesses to available[] when two customer threads call find_agent() .
- True
- False
Question 8 0.5 pts
There is a race condition in accesses to available[] when two customer thread call find_agent() .
- True
- False
Question 9 0.5 pts 操作系统quiz代写
There is a race condition in accesses to num_people when one customer thread calls find_agent() and one agent thread calls ready() .
- True
- False
Question 10 0.5 pts
There are no race conditions as long as the minimum time between people
requesting an agent is larger than the maximum time needed to run find_agent() .
- True
- False
Question 11 1 pts
The three criteria above address different properties of the critical section problem. They may not address all of them.
Critieria 1 primarily addresses the [ ] property.
Critieria 2 primarily addresses the [ ] property.
Critieria 3 primarily addresses the [ ] property.