|
pvm - parellel virtual machinesparallel virtual machines (pvm) is a strategy used in the unix environment to speed up processes by dividing them among different machines. there are several different appraoches to pvm. here are some:
my pvm programmy program uses the master-slave approach. the master asks for user input and generates that many tasks. each slave is sent an integer 0 thru the number of total tasks. upon receiving the integer, the slave calculates the square and the square root of that integer. the next part involves accessing the dictionary (/usr/dict/words) on each machine. each slaves opens the file of words and picks out the word that corresponds to the square of the integer it was sent. for example, if a slave is sent 6, it would pick out the 36th word of the list. since the dictionary contains only 45402 words, and the square of the integer might be larger than that, i made it so that it cycles around. in other words, the num MOD 45402th word is taken. the slave stores the square root, the square, and the word in variables and sends them back to the master. before receiving any data from the slaves, the master constructs an array of structs the size of the number of tasks. the struct has several parameters: original number, square root, square, and the dictionary word. data is then received from each of the slaves and placed into the array. the next step is sorting the structs in the array by the bubble sort, by far the most infamous algorithm for speed (!). in retrospect, it would have been much easier to just place each package sent by the slaves into the corresponding spot in the array... the final step is displaying everything. this is done successfully, and some windowshots can be seen below.
last but not least, here is the code for my wonderful program.
|