Tuesday, December 13, 2011

Multi-Processing


One of the main points of this multi-processing class was to become acclimated to the use of web workers to improve the execution speed of particular actions.One example we used was program that used two workers to add a group of numbers. In principle, the workers were to take turns accessing the numbers and keeping separate totals to be added together in the end.
From these results, though, we encountered a problem where one worker would do all of the work without the other worker ever having a chance involved. This problem occurs due to the setup, in which the workers communicate through the main to request access to the data and while one has access the other worker is forced to wait, which could then lead to the same worker gaining repeated access to the data. To avoid a deadlock, where both attempt to gain access at the same time causing the program to freeze or crash, a provision is added for one worker to concede to the other if they both are making a request at the same time. And this is the reason for one worker being allowed to do all of the work.
Another example used was a Pi calculator using multiple web workers. The purpose here was to observe how quickly multiple web workers could perform the calculation.
The results show that while workers perform the calculations relatively quickly, the addition of more workers increases the time it takes for all workers to complete their tasks.