Revision: 54021
          http://brlcad.svn.sourceforge.net/brlcad/?rev=54021&view=rev
Author:   brlcad
Date:     2012-12-07 05:51:27 +0000 (Fri, 07 Dec 2012)
Log Message:
-----------
accept gci task 
http://www.google-melange.com/gci/task/view/google/gci2012/8030203 from 
Adri?\195?\161n Arroyo Calle that reportedly (untested) implements for creating 
threads on windows.  this is the first of two critical pieces that get us 
closer to SMP on windows.

Modified Paths:
--------------
    brlcad/trunk/AUTHORS
    brlcad/trunk/src/libbu/parallel.c

Modified: brlcad/trunk/AUTHORS
===================================================================
--- brlcad/trunk/AUTHORS        2012-12-07 03:18:41 UTC (rev 54020)
+++ brlcad/trunk/AUTHORS        2012-12-07 05:51:27 UTC (rev 54021)
@@ -634,7 +634,11 @@
 2012 December
 Open Source (GCI)
 
+Calle, Adrián Arroyo
+2012 December
+Open Source (GCI)
 
+
 SPECIAL THANKS
 --------------
 

Modified: brlcad/trunk/src/libbu/parallel.c
===================================================================
--- brlcad/trunk/src/libbu/parallel.c   2012-12-07 03:18:41 UTC (rev 54020)
+++ brlcad/trunk/src/libbu/parallel.c   2012-12-07 05:51:27 UTC (rev 54021)
@@ -997,7 +997,7 @@
 
     /* XXX How to advise thread library that we need 'ncpu' processors? */
 
-    /* Create the threads */
+    /* Create the posix threads */
     for (x = 0; x < ncpu; x++) {
        pthread_attr_t attrs;
        pthread_attr_init(&attrs);
@@ -1066,6 +1066,44 @@
 
 #  endif /* end if posix threads */
 
+
+#  ifdef WIN32
+    /* Win32 Threads */
+
+    thread = 0;
+    nthreadc = 0;
+    DWORD   dwThreadIdArray[ncpu];
+    HANDLE  hThreadArray[ncpu] = {0};
+
+    /* Create the Win32 threads */
+
+    for( int i = 0; i < ncpu; i++){
+       hThreadArray[i] = CreateThread(
+           NULL,
+           0,
+           (LPVOID)parallel_interface,
+           NULL,
+           0,
+           &dwThreadIdArray[i]);
+       if (hThreadArray[i] == NULL) {
+           bu_log("bu_parallel(): Error in CreateThread");
+           bu_exit();
+       }
+    }
+    /* Wait for other threads in the array */
+
+    WaitForMultipleObjects(i, hThreadArray, TRUE, INFINITE);
+    for (x = 0; x < nthreadc; x++) {
+       int ret;
+       if ((ret = CloseHandle(hThreadArray[x]) != 0)) {
+           /* The thread not closing properly */
+           bu_log("bu_parallel(): Error closing threads");
+           x--;
+       }
+       nthreade++;
+    }
+#  endif /* end if Win32 threads */
+
     /*
      * Ensure that all the threads are REALLY finished.  On some
      * systems, if threads core dump, the rest of the gang keeps

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to