833 views

1 Answer

3 votes
3 votes

Let us name the given instructions as I1 , I2 and I3..

There are three different types of dependencies which are RAW , WAR and WAW hazards..

For RAW dependency to happen between Ii and Ij instructions ( i being earlier than j ) , then Ij should read the same data item as written by Ii..

So as clear from above , R4 data is written by I2 which is written by I1..Hence there is RAW dependency between I1 - I2..RAW dependencies are also known true dependencies or flow dependencies , the reason being they happen for instructions which occur in-order..So there is no scope of out of order dependencies..

For WAR dependency to happen Ii - Ij with Ii being earlier than Ij in the code , Ij should write some item and the same should be read by Ii..But this happens when instruction occurs out of order i.e. Ij occurs before Ii..Such dependencies are also known as anti dependencies..

For example , here R4 is written by I3 and read by I2 and I1..

Hence the concerned WAR dependencies are : I3 - I2 and I3 - I1..Similarly I2 writes R4 which is read by I1..Hence I2 - I1 will be WAR dependency as well..

Now coming to WAW dependency , this is also an example of dependency which occurs in case of out of order execution of instructions..This happens when two instructions write to same data item..

As here all instructions write to data item R4 only , hence all of I2 - I1 , I3 - I2 and I3 - I1 will be WAW dependencies here. WAW dependencies are also known as output dependencies..

Related questions

1 votes
1 votes
1 answer
1
Tuhin Dutta asked Dec 3, 2017
2,112 views
J1: R1 = 100J2: R1 = R2 + R4J3: R2 = R4 + 25J4: R4 = R1 + R3J5: R1 = R1 + 30Give the no of RAW, WAR and WAW hazards
3 votes
3 votes
1 answer
4
Rajesh R asked Oct 26, 2017
592 views
Number of WAR dependencies possibleR1 <- R3 + R2R3 <- R3 + R5R3 <- R2 + R3Is it 2 or 3?