<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:m =
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16448"><BASE href="x-msg://736/">
<STYLE>@font-face {
font-family: Helvetica;
}
@font-face {
font-family: Helvetica;
}
@font-face {
font-family: Calibri;
}
@font-face {
font-family: Tahoma;
}
@page WordSection1 {size: 8.5in 11.0in; margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"; FONT-SIZE: 12pt
}
LI.MsoNormal {
MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"; FONT-SIZE: 12pt
}
DIV.MsoNormal {
MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"; FONT-SIZE: 12pt
}
A:link {
COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.apple-style-span {
mso-style-name: apple-style-span
}
SPAN.EmailStyle18 {
FONT-FAMILY: "Calibri","sans-serif"; COLOR: #1f497d; mso-style-type: personal-reply
}
.MsoChpDefault {
FONT-SIZE: 10pt; mso-style-type: export-only
}
DIV.WordSection1 {
page: WordSection1
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><SPAN class=738311511-17082012><FONT color=#0000ff
size=2 face=Arial>Hello Sid,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=738311511-17082012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=738311511-17082012><FONT color=#0000ff
size=2 face=Arial>GetTickCount() is inaccurate in milliseconds interval. You
better use timeGetTime() one (you will need to link a mm
library).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=738311511-17082012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=738311511-17082012><FONT color=#0000ff
size=2 face=Arial>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.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=738311511-17082012><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=738311511-17082012><FONT color=#0000ff
size=2 face=Arial>Nikolai.</FONT></SPAN></DIV><BR>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> live-devel-bounces@ns.live555.com
[mailto:live-devel-bounces@ns.live555.com] <B>On Behalf Of </B>Sid
Price<BR><B>Sent:</B> Thursday, August 16, 2012 11:16 PM<BR><B>To:</B> 'LIVE555
Streaming Media - development & use'<BR><B>Subject:</B> Re: [Live-devel] Do
the test applications ever sleep?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=WordSection1>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">Thanks
Ross.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">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.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">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:<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt">void</SPAN><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
BasicTaskScheduler0::doEventLoop(<SPAN style="COLOR: blue">char</SPAN>*
watchVariable) {<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> <SPAN
style="COLOR: green">// Repeatedly loop, handling readble sockets and timed
events:<o:p></o:p></SPAN></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> <SPAN
style="COLOR: blue">while</SPAN> (1) {<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"> <SPAN
style="COLOR: blue">if</SPAN> (watchVariable != NULL && *watchVariable
!= 0) <SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
DWORD dwTick_1, dwTick_2 ;<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
DWORD dwTickDelta ;<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
dwTick_1 = GetTickCount();<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
SingleStep();<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
dwTick_2 = GetTickCount() ;<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
dwTickDelta = dwTick_2 - dwTick_1 ;<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
dwTick_1 = 0 ; <SPAN style="COLOR: green">// Place to
breakpoint<o:p></o:p></SPAN></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">
}<o:p></o:p></SPAN></P>
<P style="TEXT-AUTOSPACE: " class=MsoNormal><SPAN
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">}<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">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.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">Syntax.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">“dwTickDelta”
is always zero, meaning <1mS.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">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.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">Sid.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt">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.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: #1f497d; FONT-SIZE: 11pt"><o:p> </o:p></SPAN></P>
<DIV>
<DIV
style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<P class=MsoNormal><B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">From:</SPAN></B><SPAN
style="FONT-FAMILY: 'Tahoma','sans-serif'; FONT-SIZE: 10pt">
live-devel-bounces@ns.live555.com [mailto:live-devel-bounces@ns.live555.com]
<B>On Behalf Of </B>Ross Finlayson<BR><B>Sent:</B> Thursday, August 16, 2012
2:28 PM<BR><B>To:</B> LIVE555 Streaming Media - development &
use<BR><B>Subject:</B> Re: [Live-devel] Do the test applications ever
sleep?<o:p></o:p></SPAN></P></DIV></DIV>
<P class=MsoNormal><o:p> </o:p></P>
<DIV>
<BLOCKQUOTE style="MARGIN-TOP: 5pt; MARGIN-BOTTOM: 5pt">
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt">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?<o:p></o:p></SPAN></P></DIV></DIV></BLOCKQUOTE>
<DIV>
<P class=MsoNormal><o:p> </o:p></P></DIV>
<P class=MsoNormal>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.<o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><o:p> </o:p></P></DIV>
<DIV>
<P class=MsoNormal>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.<o:p></o:p></P></DIV>
<P style="MARGIN-BOTTOM: 12pt" class=MsoNormal><o:p> </o:p></P>
<DIV>
<P class=MsoNormal><SPAN class=apple-style-span><SPAN
style="FONT-FAMILY: 'Helvetica','sans-serif'; COLOR: black; FONT-SIZE: 13.5pt">Ross
Finlayson</SPAN></SPAN><SPAN
style="FONT-FAMILY: 'Helvetica','sans-serif'; COLOR: black; FONT-SIZE: 13.5pt"><BR><SPAN
class=apple-style-span>Live Networks, Inc.</SPAN><BR><SPAN
class=apple-style-span><A
href="http://www.live555.com/">http://www.live555.com/</A></SPAN></SPAN>
<o:p></o:p></P></DIV>
<P class=MsoNormal><o:p> </o:p></P></DIV></BODY></HTML>