Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Consider the following definition of an atomic test-and-set operation and assume it is available in the

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

Step by Step Solution

3.30 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

The detailed answer for the above question is provided below The correct statement is The while shou... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st edition

321321367, 978-0321321367

Students also viewed these Databases questions

Question

23. What causes astigmatismpg109

Answered: 1 week ago