Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All three images are belong to one question and CSC 432 Lab 2 Instructions: 1. The example program given below in this lab creates a

image text in transcribed
image text in transcribed
image text in transcribedAll three images are belong to one question and
CSC 432 Lab 2 Instructions: 1. The example program given below in this lab creates a race condition if two instances of it are run concurrently. You must eliminate the race condition by following these three steps a. Identify the critical section and remainder section of the program. b. Use the swap instruction to create a spinlock to prevent both processes executing in their critical sections at the same time c. Explain the limitation of this solution. RRISC [Radically Reduced Instruction Set Computerl Instructions: l. register = +value Sets the value register to be value. Value can be any positive integer 2. register @index Sets the value of register to be 3. registerxregisterY. Increases 4. @index-register Sets the value of 5. register ? linenumber If sharedMemory[index] registerX by registerY. sharedMemory[index] to be register 5. register ? linenumber If register is non-zero, go to the instruction on line linenumber. Note that the first line number in a program is line number 0. 6. register@index Swaps the values stored in register and sharedMemory[index] 7. print register Prints out register to standard output. Notes: 1. There are three registers: rl, r2, and r3. 2. There are 16 shared memory indexes from 3. The register r- always equals -1 and 4. The register rz always equals 0 and cannot 0 to 15. cannot be written to. be written to. Example Program: Comments are not allowed in the language but are added here to aid understanding. Code is written using Courier New font and comments are written in Times New Roman font. load the value 10 into register rl r3+1 r3 rl r- load the value 1 into register decrement rl (increase rl by r2 -G0 at index 0 into r2 load the shared memory value increment r2 store the value in register r2 @0r2 back to shared memory address 0. rl? 2 rl is non-zero goto line 2) r2 - G0 at index 0 into r2 print r2 while rl isn't 0 goto line 2 (if load the shared memory value print out the value in r2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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_2

Step: 3

blur-text-image_3

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

Ehs 2.0 Revolutionizing The Future Of Safety With Digital Technology

Authors: Tony Mudd

1st Edition

B0CN69B3HW, 979-8867463663

More Books

Students also viewed these Databases questions