Using Erlang to implement a simple token passing architecture and parallelized version of mergesort.
Compile :
erlc <File>.erl
Run
erl -noshell -s <File> main input.txt output.txt -s init stop
──> README.md // Instructions
──> 20171114_1.erl // Integer Token Passing
──> 20171114_2.erl // Parallelized version of mergesort
- The initiator process forms a chain of processes and passes the token through the chain in a ring like fashion.
- After using
spawn_link
to form a chain of processes, the initiator passes the token to the last process of the chain. - The program is terminated when the token reaches the initiator again.
- We divide the array of Integers into 8 processes.
- All the processes sort the processes locally and return the result to their parent for merging.
- Eventually, the initiator receives the sorted Array,which it prints to output file.
Feel free to contribute ❤️