HWStudy Guide Synchronization Make sure you understand the
- Slides: 13
HW/Study Guide
Synchronization • Make sure you understand the HW problems!
global shared int counter = 0, BUFFER_SIZE = 10 ; Producer: while (1) { while (counter == BUFFER_SIZE); // do nothing buffer[in] = next. Produced; in = (in + 1) % BUFFER_SIZE; counter++; }
Consumer: while (1) { while (counter == 0); // do nothing next. Consumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; counter--; // consume the item }
• Identify the race condition in this version of the consumer/producer problem. • Fix this race condition using the Test. And. Set hardware instruction. • Now assume there is still one producer but there are now two consumers. – Does this introduce any additional race conditions (the correct answer is yes!)?
• If so, where does it occur? • Now fix this additional race condition using a semaphore.
• Assume I have just learned about using semaphores to synchronize the order in which certain statements are executed. • I think this is really cool, and want to give it a try. So I want to use semaphores to enforce the following execution order: – Statement S 1 of process P 1 executes before statement S 2 of process P 2. – Statement S 2 of process P 2 executes before statement S 3 of Process P 3.
• Statement S 3 of process P 3 executes before Statement S 1 of process P 1. • Use semaphores to enforce this ordering, or, show this may not be such a great idea (i. e. , what is the problem here? ).
• • Now assume we have four processes and want Statement S 1 in P 1 to execute before statement S 2 in P 2 before S 3 in P 3. Also, we want Statement S 4 in P 4 to execute after S 2 in P 2. Use semaphores to enforce this ordering. You must explicitly initialize any semaphores you use.
• Assume there is one producer process and one consumer process, and that they share a buffer with 10 slots. • Implement the producer/consumer problem using semaphores. You must explicitly initialize the semaphores that you use.
Paging • Assume a 16 -bit virtual address space with pages that are 2048 bytes. How many pages are in the logical address space? • Consider the following page table for some process in this system. 0 2 1 3 21
Paging • Consider the following page table for some process in this system, and assume the logical address is 2052. To what physical address will this logical address be mapped? Show the steps you took to determine this address. 0 2 1 3 21
• What is the Translation Lookaside buffer? • What purpose does it serve? • Consider a 64 -bit address space with 4 K pages. How many pages are there in this virtual address space? • Is this a big number? • You will most likely be asked to work through a two-level page table example.
- To understand recursion you must understand recursion
- When drawing conclusions, make sure you
- Are you sure you have a strategy
- How to avoid incremental plagiarism
- What preparations had montressor made for his revenge?
- Make me understand
- Make me understand
- Make me understand
- Make me understand
- Make me understand
- Make me understand
- Be sure of this i am with you always
- Are you sure this is safe
- I am sure you have heard something like