This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: use pthread under winCE


Hi Benoit,

I've attached my modifications to the ptw32_getprocessors.c file that fixes the GetProcessAffinityMask for WINCE. It just forces the processor count to one.

I looked in the pthread.h file and found that if you don't have _UWIN defined, pthreads own internal _errno will be used. Make sure _UWIN is *not* defined. See line 1143 in pthread.h.

It was many moons ago that I tweaked pthreads for WIN32 for WINCE and I've forgotten much of what needed to be done. If anyone wants a diff of my build against the current CVS version just let me know and I'll send it out. It might be a good idea to test it a bit and then merge it into the main CVS tree. I use the same source for both WIN32 and WINCE pthreads builds.

Best,

James


[ ptw32_getprocessors.c] ---------------------------------------------------------------------- /* * ptw32_getprocessors() * * Get the number of CPUs available to the process. * * If the available number of CPUs is 1 then pthread_spin_lock() * will block rather than spin if the lock is already owned. * * pthread_spin_init() calls this routine when initialising * a spinlock. If the number of available processors changes * (after a call to SetProcessAffinityMask()) then only * newly initialised spinlocks will notice. */ int ptw32_getprocessors(int * count) { int result = 0;

#ifndef WINCE
 DWORD vProcessCPUs;
 DWORD vSystemCPUs;

 if (GetProcessAffinityMask(GetCurrentProcess(),
                &vProcessCPUs,
                &vSystemCPUs))
   {
     DWORD bit;
     int CPUs = 0;

     for (bit = 1; bit != 0; bit <<= 1)
   {
     if (vProcessCPUs & bit)
       {
         CPUs++;
       }
   }
     *count = CPUs;
   }
 else
   {
     result = EAGAIN;
   }
#else
 *count = 1;
#endif
 return(result);
// end of file -----------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]