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

Nikolai Vorontsov nikolai.vorontsov at quadrox.be
Fri Aug 17 04:18:22 PDT 2012


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/3d7d71fa/attachment-0001.html>


More information about the live-devel mailing list