Previous 199869 Revisions Next

r32226 Saturday 20th September, 2014 at 08:40:48 UTC by Oliver Stöneberg
removed cpu mask and thread affinity code from src/osd/sdl/sdlwork.c as suggested by couriersud (nw)
[src/osd/sdl]sdlwork.c

trunk/src/osd/sdl/sdlwork.c
r32225r32226
4545//============================================================
4646
4747#define ENV_PROCESSORS               "OSDPROCESSORS"
48#define ENV_CPUMASKS                 "OSDCPUMASKS"
4948#define ENV_WORKQUEUEMAXTHREADS      "OSDWORKQUEUEMAXTHREADS"
5049
5150#define INFINITE                (osd_ticks_per_second() *  (osd_ticks_t) 10000)
r32225r32226
138137//============================================================
139138
140139static int effective_num_processors(void);
141static UINT32 effective_cpu_mask(int index);
142140static void * worker_thread_entry(void *param);
143141static void worker_thread_process(osd_work_queue *queue, work_thread_info *thread);
144142
r32225r32226
220218         osd_thread_adjust_priority(thread->handle, 1);
221219      else
222220         osd_thread_adjust_priority(thread->handle, 0);
223
224      // Bind main thread to cpu 0
225      osd_thread_cpu_affinity(NULL, effective_cpu_mask(0));
226
227      if (flags & WORK_QUEUE_FLAG_IO)
228         osd_thread_cpu_affinity(thread->handle, effective_cpu_mask(1));
229      else
230         osd_thread_cpu_affinity(thread->handle, effective_cpu_mask(2+threadnum) );
231221   }
232222
233223   // start a timer going for "waittime" on the main thread
r32225r32226
593583   }
594584}
595585
596//============================================================
597//  effective_cpu_mask
598//============================================================
599586
600static UINT32 effective_cpu_mask(int index)
601{
602   char    *s;
603   char    buf[5];
604   UINT32  mask = 0xFFFF;
605
606   s = osd_getenv(ENV_CPUMASKS);
607   if (s != NULL && strcmp(s,"none"))
608   {
609      if (!strcmp(s,"auto"))
610      {
611         if (index<2)
612            mask = 0x01; /* main thread and io threads on cpu #0 */
613         else
614            mask = (1 << (((index - 1) % (osd_get_num_processors() - 1)) + 1));
615      }
616      else
617      {
618         if (strlen(s) % 4 != 0 || strlen(s) < (index+1)*4)
619         {
620            fprintf(stderr,"Invalid cpu mask @index %d: %s\n", index, s);
621         }
622         else
623         {
624            memcpy(buf,s+4*index,4);
625            buf[4] = 0;
626            if (sscanf(buf, "%04x", &mask) != 1)
627               fprintf(stderr,"Invalid cpu mask element %d: %s\n", index, buf);
628         }
629      }
630   }
631   return mask;
632}
633
634587//============================================================
635588//  worker_thread_entry
636589//============================================================

Previous 199869 Revisions Next


© 1997-2024 The MAME Team