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
-
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...
-
The company that you work for as a managerial accountant uses independent agents to sell its products. These agents are currently being paid a commission of 15% of the sales price but are asking for...
-
Find the area of the surface generated when the given curve is revolved about the x-axis. x/2 y = x3/2 on [1, 2] 3
-
The acentric factor can be mathematically expressed as (a) \(\omega=-1-\left.\log _{10} P_{r}^{\text {sat }} ight|_{T_{r}=0.7}\) (b) \(\omega=1-\left.\log _{10} P_{r}^{\text {sat }}...
-
Kardash Cosmetics purchases flowers in bulk and processes them into perfume. From a certain mix of petals, the firm uses Process A to generate Seduction, its high-grade perfume, as well as a certain...
-
5. a) Use the sine law to find the length of side c. 3 cm C A 40 2=> 65 b) Use the sine law to find the measure of ZP. Q 15 cm P 7 cm 110 R Use the cosine law to find the measure of E. 8 mm
-
The beginning inventory at Midnight Supplies and data on purchases and sales for a three month period ending March 31 are as follows: Date Transaction Number of Units Per Unit Total Jan. 1 Inventory...
-
Instructions The purpose of this assignment is to give you an opportunity to evaluate a product category based on available market data, and to use library resources that are relevant to marketers....
-
Several professional roles were identified in the chapter. Identify five and reflect on why you would like or not like to perform that role in strategic communication practice.
-
Identify an organization or institution you are familiar with and identify the kind or kinds of structure it uses. Describe the structural attributes you have identified.
-
What are the components of a print ad?
-
A \(69-\mathrm{kV}\) circuit breaker has a voltage range factor \(\mathrm{K}=1.21\), a continuous current rating of \(1200 \mathrm{~A}\), and a rated short-circuit current of \(19,000 \mathrm{~A}\)...
-
Explain the ROPE process. Why is it helpful to strategic communication?
-
(a) A number of landfill investigation studies have suggested that the stabilization of waste proceeds in five sequential and distinct phases. During these phases, the rate and characteristics of...
-
Suppose the market is semistrong form efficient. Can you expect to earn excess returns if you make trades based on? a. Your brokers information about record earnings for a stock? b. Rumors about a...
-
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...
-
Applying the criterion for equilibrium, derive the Clausius-Clapeyron equation.
-
For the system methanol (1)-methyl acetate (2), the activity coefficients for components 1 and 2 are represented by where \[ \begin{aligned} \ln \gamma_{1} & =A x_{2}^{2} \quad \text { and } \quad...
-
The pure component vapour pressure of two organic liquids \(\mathrm{X}\) and \(\mathrm{Y}\) by Antoine equations are given by \[ \ln P_{1}^{\text {Sat }}=14.35-\frac{2942}{T+220} \] and \[...
Study smarter with the SolutionInn App