next up previous
Next: int pvm_start_farmd(void); Up: int pvm_farm_terminate(char *farm_name); Previous: Client side

Server side

  1. Receive the message and check if opcode is FARM_TERMINATE and get the tid of the client.
  2. Search for the farm using the farm name.
  3. If its not found, return a value NO_SUCH_FARM to the client.
  4. If its found, check the client tid and the tid of the creator of the farm. If they do not match send a return value NOT_FARM_OWNER to the client.
  5. If everything is OK, keep on popping all worker classes from the list of worker classes till there are no more worker classes.
  6. In each worker class, get the worker class id and reset the entry in the Cache of the worker classes which contains the worker class id and the pointer to the worker class item.
  7. Then in the worker class while there are still worker items which have no packets pending (the ones which are blocked on the pvm_recv_work_packet() request), process each worker item.
  8. Send a message to the worker tasks which contains the integer FARM_HAS_TERMINATED with message tag of FARM_HAS_TERMINATED.
  9. Set the number of packets pending as a non-zero number (1) so that the next search does not return the same entry.
  10. Do the housekeeping with the buffer used for sending the message to the worker.
  11. After all the blocked workers in the worker class have been sent this message, delete the worker list and the pending work packet list associated with the worker class.
  12. After all the worker classes have been processed, delete the worker class list (thereby destroying all worker classes associated with the farm).
  13. Delete the farm item entry from the list of farms using the farm name.
  14. Return a message OK to the farmer waiting for conformation on the farm.
  15. Look for other messages.


next up previous
Next: int pvm_start_farmd(void); Up: int pvm_farm_terminate(char *farm_name); Previous: Client side



Sameer Shende