Reputation: 89
I have been given 4 processes , where processes have a dependency on others. For example :
x1:[x2,x3]
x2:[x3]
x3:[]
This means x1 starts only once x2 and x3 are complete x2 starts only when x3 is complete x3 can start as it does not have any dependence on any other process. I have to figure out strategy to find the order of execution of processes.
What would be the best way to solve this problem?.
Upvotes: 3
Views: 222
Reputation: 7612
I guess its a clear case of topological sorting of graph which is used to resolve dependencies, Here we need to create a directed graph with nodes as the processes you mentioned. Now there is a directed edge from x1 to x2 if x1 is dependent on x2 and so on. Once graph is created, topological sort on the graph is your answer.
Upvotes: 7