6. Initial value of shared variable m is equal to 0 and it is stored at memory address 1100. threads A, B, Y, Z use this variable as follows: Processes A and B increase the value of m by 1. Processes Y and Z decrease the value of m by 1. Since m is shared, each process protects the critical region using semaphore S initialized to 2. Write the sequence of operations so that after each thread is executed once, the value of m is equal to-2. assume the code is used S=2 Proses A A1: W(S) A2: LOAD m, 1100 A3: ADD 1 A4: MV A, 1100 A5: S(S) Proses B B1; W(S) B2: LOAD m, 1100 83: SUBT 1 B4: MV A, 1100 B5: S(S) Proses Y Y1: W(S) Y2: LOAD m, 1100 Y3: ADD 1 Y4: MV A, 1100 Y5: S(S) Proses 2 21: W(S) 22: LOAD m, 1100 23: SUBT 1 24: MV A, 1100 25:5(5)

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter11: Operating Systems
Section: Chapter Questions
Problem 5RQ
icon
Related questions
Question
6. Initial value of shared variable m is equal to 0 and it is stored at memory address 1100. Four
threads A, B, Y, Z use this variable as follows: Processes A and B increase the value of m by 1.
Processes Y and Z decrease the value of m by 1. Since m is shared, each process protects the
critical region using semaphore S initialized to 2. Write the sequence of operations so that after
each thread is executed once, the value of m is equal to -2.3
assume the code is used
S=2
Proses A
A1: W(S)
A2: LOAD m, 1100
A3: ADD 1
A4: MV A, 1100
A5: S(S)
Proses B
B1; W(S)
B2: LOAD m, 1100
83: SUBT 1
B4: MV A, 1100
85: S(S)
Proses Y
Y1: W(S)
Y2: LOAD m, 1100
Y3: ADD 1
Y4: MV A, 1100
Y5: S(S)
Proses 2
21: W(S)
22: LOAD m, 1100
23: SUBT 1
24: MV A, 1100
25: S(S)
Transcribed Image Text:6. Initial value of shared variable m is equal to 0 and it is stored at memory address 1100. Four threads A, B, Y, Z use this variable as follows: Processes A and B increase the value of m by 1. Processes Y and Z decrease the value of m by 1. Since m is shared, each process protects the critical region using semaphore S initialized to 2. Write the sequence of operations so that after each thread is executed once, the value of m is equal to -2.3 assume the code is used S=2 Proses A A1: W(S) A2: LOAD m, 1100 A3: ADD 1 A4: MV A, 1100 A5: S(S) Proses B B1; W(S) B2: LOAD m, 1100 83: SUBT 1 B4: MV A, 1100 85: S(S) Proses Y Y1: W(S) Y2: LOAD m, 1100 Y3: ADD 1 Y4: MV A, 1100 Y5: S(S) Proses 2 21: W(S) 22: LOAD m, 1100 23: SUBT 1 24: MV A, 1100 25: S(S)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning