Consider the following definition of an atomic test-and-set operation and assume it is available in the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following definition of an atomic test-and-set operation and assume it is available in the assembly-language instruction set for xv6. Note that "test-and-set" is not a very precise name for this primitive; a better name would be "set and return prior value". // Note I have to use # instead of to indicate dereferencing, because Gradescope parses the as a formatting indicator boolean TestAndSet(boolean_ref &lock) { boolean initial = #lock; // get current value #lock = true; // set value to true return initial; // return the value we read, for caller to test } Now consider this implementation of a spinlock in xv6: void acquire(struct spinlock *Ik) { pushcli(): if(holding (Ik)) panic("acquire"); while(TestAndSet(&lk->locked) != 0) ; _sync synchronize(): } Which of these statements is true? O This implementation is correct O The while loop is not needed The while should be testing "!= 1", instead of "!=0" The sync synchronize() is not needed Consider the following definition of an atomic test-and-set operation and assume it is available in the assembly-language instruction set for xv6. Note that "test-and-set" is not a very precise name for this primitive; a better name would be "set and return prior value". // Note I have to use # instead of to indicate dereferencing, because Gradescope parses the as a formatting indicator boolean TestAndSet(boolean_ref &lock) { boolean initial = #lock; // get current value #lock = true; // set value to true return initial; // return the value we read, for caller to test } Now consider this implementation of a spinlock in xv6: void acquire(struct spinlock *Ik) { pushcli(): if(holding (Ik)) panic("acquire"); while(TestAndSet(&lk->locked) != 0) ; _sync synchronize(): } Which of these statements is true? O This implementation is correct O The while loop is not needed The while should be testing "!= 1", instead of "!=0" The sync synchronize() is not needed
Expert Answer:
Answer rating: 100% (QA)
The detailed answer for the above question is provided below The correct statement is The while shou... View the full answer
Related Book For
Introduction to Data Mining
ISBN: 978-0321321367
1st edition
Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar
Posted Date:
Students also viewed these databases questions
-
ces Alyeski Tours operates day tours of coastal glaciers in Alaska on its tour boat the Blue Glacier. Management has identified two cost drivers-the number of cruises and the number of...
-
Consider the following definition of an anomaly: An anomaly is an object that is unusually influential in the creation of a data model. (a) Compare this definition to that of the standard model-based...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
This section contains 6 questions. Questions 83 to 88 have four statements (A, B C and D) given in Column I and four statements (p, q, r and s) in Column II. Any given statement in Column I can have...
-
What concerns would you have when electroplating P/M parts? Explain.
-
The following report appeared in the New York Times on August 7, 1989 (Dollars Strength a Surprise, p. D1): But now the sentiment is that the economy is heading for a soft landing, with the economy...
-
\(\{3,927,473,82,709,1,210,121\}\) Find the greatest common divisor of the given set of numbers.
-
House of Organs, Inc., purchases organs from a well-known manufacturer and sells them at the retail level. The organs sell, on the average, for $2,500 each. The average cost of an organ from the...
-
estion 8 rrect rk 1.00 out of 1.00 g question stion text e following information is available for adshaw Corporation and Newell Corporation: Bradshaw Corporation Newell Cor 2015 2014 2015 25 10 0 500...
-
On January 1, 2025, Carla Vista Company has the following defined benefit pension plan balances. Projected benefit obligation Fair value of plan assets $4,569,000 4,160,000 The interest (settlement)...
-
1 . Assembly Line Balancing [ 1 0 + 1 0 + 5 + 5 + 5 points ] : ( e ) If a 4 - station assembly line with cycle time, C = 4 0 seconds has station times 3 6 , 3 4 , 3 5 and 3 3 seconds what is the...
-
Department J had no work in process at the beginning of the period, 18,000 units were completed during the period, 2,000 units were 30% completed at the end of the period, and the following...
-
D-R 1.5 (7 pts) Daneel is now pushing harder and finally gets the fridge and Susan sitting on top of it to move together. Daneel is applying a constant force FNR= 1000N and managed to get the fridge...
-
How might the concept of distributive justice be applied to address disparities in access to advanced medical treatments and emerging technologies across different socio-economic strata ?
-
Compose an Essay Write an essay to describe how the government protects individuals against discrimination. Your essay should include at least four paragraphs. In the first paragraph, explain an...
-
Mr Coetzee works for an advertising company, Litaba Ltd. In his spare time, he writes articles for an online news website, Lesedi News. On this website he publishes an article (which he wrote from...
-
Think about a process that you participate in as a customer (e.g. a bank, a restaurant, a doctor's office, airport, retail store, etc.) that seems to operate ineffectively. Your goal is to improve...
-
The Heese Restaurant Group manufactures the bags of frozen French fries used at its franchised restaurants. Last week, Heeses purchased and used 101,000 pounds of potatoes at a price of $ 0.70 per...
-
Consider the data set shown in Table 6.1. (a) Compute the support for itemsets {e}, {b, d}, and {b, d, e} by treating each transaction ID as a market basket. (b) Use the results in part (a) to...
-
For each type of pattern defined below, determine whether the support measure is monotone, anti-monotone, or non-monotone (i.e., neither monotone nor anti-monotone) with respect to increasing itemset...
-
You are given two sets of 100 points that fall within the unit square. One set of points is arranged so that the points are uniformly spaced. The other set of points is generated from a uniform...
-
1.9 Aidan's Globalization. After reading the chapter's description of Aidan's globalization process, how would you explain the distinctions between interna- tional, multinational, and global...
-
1.10 Aidan, the MNE. At what point in the globalization process did Aidan become a multinational enter- prise (MNE)?
-
1.8 International Financial Management. What is differ- ent about international financial management?
Study smarter with the SolutionInn App