- Author: Valerene Goh Ze Yi
- ID: 1002457
- Date: 09/03/2018
This program traverses a directed acyclic graph (DAG) of user programs from an input text file in parallel, while fulfilling both contol and data dependencies between each other. Multithreading is implemented for the processes that are labelled runnable for that particular iteration. The diagram shows a visual representaion of the DAG traversal for a corresponding graph file.
This program works much better in Linux than Windows. It is suggested that you use a Virtual Machine such as Ubuntu to run it if you are not a Linux user.
- Change directory (using the command
cd) to the directory location containing all your files. - Compile the java file using the following command:
$ javac ProcessManagement.java
- Run the java file using the following command, whereby
[arg]is either one of:graph-file/graph-file1/graph-file2/graph-file3:
$ java ProcessManagement [arg]
- Download the zip folder and extract its contents.
- In
ProcessManagement.java, ensure that user.dir is the directory location containing all your files. - Under Edit Configurations, input either one of:
graph-file/graph-file1/graph-file2/graph-file3. Alternatively, you can directly edit the file path forinstructionSetto the file path of your chosen graph file. - Run
ProcessManagement.javato start the program.
ProcessManagement.java passes the graph file into ParseFile.java.
The program ProcessManagement reads it line by line and parses the information contained in it (colon delimited). Each node of the graph is represented by a line with the following format (space-delimited for multiple arguments):
program name with arguments:list of children ID's:input file:output file
The program first checks if all nodes have been executed and if a cycle exists in the graph (all process nodes are not runnable while there still exist unexecuted process nodes), subject to race condition. This feature is part of deadlock prevention.
If none if this is fulfilled (i.e. not all have been executed and there isn't a cycle), we iterate through every process node in the DAG and set it to runnable if it is runnable. Then, for the runnable nodes, multithreading executes them concurrently for each iteration of the while loop. The order in which the process nodes are executed will be printed in the terminal.
The program terminates when all nodes have been executed successfully or when the program finds an error (e.g. a cycle causing deadlock).
