9f3f48b4caaef5365b1426d7b4e69bf90f57ded5
kent
  Tue Feb 3 13:53:06 2015 -0800
Utility for multithreaded md5 calculation seems to work.

diff --git src/utils/paraMd5/paraMd5.c src/utils/paraMd5/paraMd5.c
new file mode 100644
index 0000000..f53b790
--- /dev/null
+++ src/utils/paraMd5/paraMd5.c
@@ -0,0 +1,74 @@
+/* paraMd5 - Make md5 sums for files in parallel.. */
+#include "common.h"
+#include "linefile.h"
+#include "hash.h"
+#include "options.h"
+#include "md5.h"
+#include "pthreadDoList.h"
+
+int threads = 5;
+
+void usage()
+/* Explain usage and exit. */
+{
+errAbort(
+  "paraMd5 - Make md5 sums for files in parallel.\n"
+  "usage:\n"
+  "   paraMd5 XXX\n"
+  "options:\n"
+  "   -threads=N - number of threads - default %d\n"
+  , threads
+  );
+}
+
+/* Command line validation table. */
+static struct optionSpec options[] = {
+   {"threads", OPTION_INT},
+   {NULL, 0},
+};
+
+struct paraMd5
+/* Keep track of a number and it's Nth power in parallel */
+    {
+    struct paraMd5 *next;
+    char *fileName; /* Name of file */
+    char *md5;	    /* Md5sum */
+    };
+
+void doPowerCalc(void *item, void *context)
+/* This routine does the actual work. */
+{
+struct paraMd5 *p = item; // Convert item to known type
+p->md5 = md5HexForFile(p->fileName);
+}
+
+
+void paraMd5(int fileCount, char *files[])
+/* paraMd5 - Make md5 sums for files in parallel.. */
+{
+struct paraMd5 *list = NULL, *el;
+int i;
+for (i=0; i<fileCount; ++i)
+    {
+    AllocVar(el);
+    el->fileName = files[i];
+    slAddHead(&list, el);
+    }
+slReverse(&list);
+pthreadDoList(threads, list, doPowerCalc, NULL);
+for (el = list; el != NULL; el = el->next)
+    {
+    printf("%s  %s\n", el->md5, el->fileName);
+    }
+}
+
+int main(int argc, char *argv[])
+/* Process command line. */
+{
+optionInit(&argc, argv, options);
+if (argc < 2)
+    usage();
+threads = optionInt("threads", threads);
+paraMd5(argc-1, argv+1);
+return 0;
+}