c++ - How to optimize thread effciency(CPU cost) when fix the thread loop time -


i use lib phtread 2.8 , os kernal linux 2.6.37 on arm. write multi-thread program: thread :using phtread interface create , set priority half of sched_get_priority_min(policy) , max.

in thread function loop:

{ //do work pthread_cond_timedwait(..., ... , 15 ms) } 

i find thread cost 3% cpu. if wait 30 ms. reduce 1.3%. but, can not increase wait time. whether there way reduce cpu cost.it seams cost thread switch.

using sort of construct cause approximately 67 task switches per second, , switches different process, means complete context switch including page-tables. it's been while since looked @ involves in arm, i'm sure it's not "lightweight" operation. if count backwards, 1.75% of 210k clock cycles per task switch. seems quite lot. i'm not sure how work involved in scrubbing tlb's, caches , such.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -