[Live-devel] Do the test applications ever sleep?

Sid Price sidprice at softtools.com
Fri Aug 17 08:17:50 PDT 2012


Hello Nikolai,

 

Thank you for taking the time to reply to my questions.

 

I am well aware of the resolution of "GetTickCount()," I even mentioned it
in an earlier post. Gicen the times we are trying to confirm it is more than
adequate.

 

Also, Ross has explained very well the way the process operates in a
response to me earlier and events are not involved.

 

I have run performance monitoring, again mentioned in an earlier post and I
know pretty well that the "OnDemandRTSPServer" is consuming about 7% of my
CPU time when Idle (just ran the tests and the earlier figure I quoted was
not accurate). My hope was to reduce this to an absolute minimum by changing
to a true event driven server. However I am not sure how practical that is
without changing Ross' basic code and I do not want to do that.

 

Again, thank you,

Sid.

 

From: live-devel-bounces at ns.live555.com
[mailto:live-devel-bounces at ns.live555.com] On Behalf Of Nikolai Vorontsov
Sent: Friday, August 17, 2012 5:18 AM
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] Do the test applications ever sleep?

 

Hello Sid,

 

GetTickCount() is inaccurate in milliseconds interval. You better use
timeGetTime() one (you will need to link a mm library).

 

In any case I suppose that Ross holds the working thread on an event or
something and thus efficiently release any time slices. Do a simple test -
run idle server and check how much CPU it uses.

 

Nikolai.

 

  _____  

From: live-devel-bounces at ns.live555.com
[mailto:live-devel-bounces at ns.live555.com] On Behalf Of Sid Price
Sent: Thursday, August 16, 2012 11:16 PM
To: 'LIVE555 Streaming Media - development & use'
Subject: Re: [Live-devel] Do the test applications ever sleep?

Thanks Ross.

 

I used the word "sleeping" to mean that the process gives up any remaining
time from its current time-slice for the OS to allocate as required.

 

Using your information I did some more digging and if I measure the
execution time of "SingleStep" when the OnDemandRTSPServer application is
running with no client connections  I see <1mS execution time. I think my
test code is good:

 

void BasicTaskScheduler0::doEventLoop(char* watchVariable) {

  // Repeatedly loop, handling readble sockets and timed events:

  while (1) {

    if (watchVariable != NULL && *watchVariable != 0) break;

      DWORD dwTick_1, dwTick_2 ;

      DWORD dwTickDelta ;

      dwTick_1 = GetTickCount();

    SingleStep();

      dwTick_2 = GetTickCount() ;

      dwTickDelta = dwTick_2 - dwTick_1 ;

      dwTick_1 = 0 ;    // Place to breakpoint

  }

}

 

GetTickCount is a Windows API that retrieves the number of milliseconds that
have elapsed since the system was started, up to 49.7 days, then it wraps.

 

Syntax.

 

"dwTickDelta" is always zero, meaning <1mS.

 

What led me here was that I used a process monitor to measure the CPU % that
the test application was consuming and when I have no client attached and
therefore no streaming happening I see higher CPU usage than I expected. In
the range 15-25% of CPU. The CPU is a fast ARM that should be more than
enough horsepower for this task.

 

Sid.

 

 

Since there is nothing else in the "doEventLoop" I terms of calls I have to
assume the 10mS you mentioned should be the execution time of the
"SingleStep" method.

 

From: live-devel-bounces at ns.live555.com
[mailto:live-devel-bounces at ns.live555.com] On Behalf Of Ross Finlayson
Sent: Thursday, August 16, 2012 2:28 PM
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] Do the test applications ever sleep?

 

While investigating another issue I began to dig a little deeper into how
the library operates and it appears to me that the process running the
servers never sleeps, is this correct?

 

Not really.  I don't know what specifically you mean by 'sleep', but - as
you know - LIVE555-based applications are event driven, and execute code
only when handling an event.  When there are no events to be handled, then
the application does not run.  You can call this 'sleeping' if you like.

 

What you might be referring to, however, is the fact that - in the
"BasicTaskScheduler" implementation - there is a periodic delayed task
called "schedulerTickTask()" that runs every 10 milliseconds (not 10
microseconds as the comment in the code incorrectly says).  This task does
no work, and exists only to ensure that the code periodically returns from
"select()", to handle any triggered events.  But this causes only a brief
period of activity (with almost no overhead) every 10 ms; for the rest of
the time, the application is effectively 'sleeping' if there are no other
events to be handled.

 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/ 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120817/76bb9adf/attachment.html>


More information about the live-devel mailing list