Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # schedule
- schedule = "r1(x) r1(y) w2(x) w1(x) r2(y)".split(' ')
- final_schedule = {}
- cycles = {}
- i_index = 0
- for i in schedule:
- i_index += 1
- i_operation_type, i_transaction, i_operator = i[0], i[1], i[3]
- j_index = 0
- for j in schedule:
- j_index += 1
- j_operation_type, j_transaction, j_operator = j[0], j[1], j[3]
- if((i_transaction != j_transaction) and (i_operator == j_operator) and (i_operation_type+''+j_operation_type != 'rr') and j_index > i_index):
- if(i_transaction + '' + j_transaction not in final_schedule.values()):
- final_schedule[i + '-->' + j] = i_transaction + '' + j_transaction
- # print(final_schedule)
- for k,v in final_schedule.items():
- for k1,v1 in final_schedule.items():
- if(v == v1[::-1]):
- cycles[k] = v
- print("Schedule: ")
- for k,v in final_schedule.items():
- print('T'+v[0]+' --> '+'T'+v[1])
- if(len(cycles)):
- print("Cycles found: ")
- for k,v in cycles.items():
- print('T'+v[0]+' --> '+'T'+v[1], end=" ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement