[pjsip] CPU utilization 100% for clock_threads

M.S. hamstiede at yahoo.de
Tue Jun 2 09:38:32 EDT 2009


Hi,
in my application i used more than one conference bridge with separate master_ports.
i have a "small" arm system  with a Linux 2.6  kernel .

if i have one connection everything is ok. (CPU use for the clock_thread < 3%)
if i have more than 3 connection with running clock threads, the last running clock_thread will use >90% cpu utilization.

the problem is the clock_thread sleep code in clock_thread.c
static int clock_thread(void *arg)
{
....
    if (now.u64 < clock->next_tick.u64) {
        unsigned msec;
        msec = pj_elapsed_msec(&now, &clock->next_tick);
        pj_thread_sleep(msec);
    }
...
}

if the if sleep statement will not reached the thread will not yield(). At this moment everything goes wrong. I think the linux scheduler will not left the thread without a yield and
will run this fuction to often.
The highest thread prio config for this thread will force this situation.
I make a small change and everything looks better:
 
   if (now.u64 < clock->next_tick.u64) {

        unsigned msec;

        msec = pj_elapsed_msec(&now, &clock->next_tick);

        pj_thread_sleep(msec);

    } 
    else
    {
      pj_thread_sleep(1); /** the linux scheduler will left this thread !!*/
   }

Now i have a better situation, the six clock threads will use 40% together.

regards 

   Mark





      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090602/521d3d56/attachment.html>


More information about the pjsip mailing list