EBK COMPUTER SYSTEMS
EBK COMPUTER SYSTEMS
3rd Edition
ISBN: 8220101459107
Author: O'HALLARON
Publisher: YUZU
Expert Solution & Answer
Book Icon
Chapter 12.5, Problem 12.7PP

Explanation of Solution

Instruction ordering of “badcnt.c”:

  • When performing instruction “H1”, the value of “%rdx1” and “%rdx2” is null and “cnt” value is “0”.
  • When performing instruction “L1”:
    • The instruction “L1” means loads the shared variable “cnt” into register “%rdx1”.
      • Hence, the value of “%rdx1” contains the value of “cnt” variable.
      • Therefore, %rdx1=0
  • When performing instruction “H1”, the value of “%rdx1” and “%rdx2” is null and “cnt” value is “0”.
  • When performing instruction “L2”:
    • The instruction “L2” means loads the shared variable “cnt” into register “%rdx2”.
      • Hence, the value of “%rdx2” contains the value of “cnt” variable.
      • Therefore, %rdx2=0
  • When performing instruction “U2”:
    • The instruction “U2” means update value in register “%rdx2”.
      • Update value means increment the value of “%rdx2” by “1”.

        %rdx2=%rdx2+1=0+1%rdx2=1

      • Therefore, %rdx2=1 and the value of “cnt” is “0”. Here, the “cnt” will be not be update. It only update after the instruction stored.
  • When performing instruction “S2”:
    • The instruction “S2” means store the updated value of register “%rdx2” into “cnt”.
      • Hence, %rdx2=1 and “cnt” value is “1”.
  • When performing instruction “U1”:
    • The instruction “U1” means update value in register “%rdx1”.
      • Update value means increment the value of “%rdx1” by “1”

Blurred answer
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY