Hello Babacar,

what is your definition of "context switching time"? To measure short time intervals with little overhead, you can use the rtems_counter_read() function (not supported on all BSPs).

The tmcontext01 test measures the low-level context switch time. To get some samples for the thread dispatch time, you can enable profiling (--enable-profiling configure command line option) and use the test suite. Collect the output of all the tests and filter out the non-XML data (filter-test-xml.py). Then you can use this XML file to get some statistics (e.g. boxplot.py).

On 07/09/16 22:10, Babacar Diop wrote:

Dear devels,

I am using a multithreaded task and I would like to measure the context switching time.

Do you have any idea on how to do this ?

Kind Regards
------------------------------------------------------------------------------------------------------------------------

Babacar Diop
23 ans
Élève ingénieur à Polytech' Paris-UPMC
Section Électronique, Informatique des Systèmes Embarqués
Année 5



_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  :sebastian.hu...@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

#!/usr/bin/python
#
# Copyright (c) 2014 embedded brains GmbH
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import libxml2
from libxml2 import xmlNode
import matplotlib.pyplot as plt

def m(n):
	return [int(n.getContent()), n.get_parent().get_parent().prop("name")][0]

def getData(name):
	doc = libxml2.parseFile(name)
	ctx = doc.xpathNewContext()
	return map(m, ctx.xpathEval('/ProfilingCollection/ProfilingReport/PerCPUProfilingReport/MaxThreadDispatchDisabledTime'))

cmPerInch = 2.54
plt.figure(figsize = (18.0 / cmPerInch, 18.0 / 1.618 / cmPerInch))
plt.boxplot(getData('tests.xml'), 0, 'rs');
plt.ylabel('max thread dispatch disabled time [ns]')
plt.yscale('log')
plt.savefig('max-thread-dispatch-disabled-times-log.png')
#!/usr/bin/python
#
# Copyright (c) 2014 embedded brains GmbH
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sys
import re

print "<ProfilingCollection>"

while True:
	line = sys.stdin.readline()
	if not line:
		break
	m = re.match('^\s*<pause.*>\s*$', line)
	if m:
		continue
	m = re.match('^\s*<assocnamebad.*>\s*$', line)
	if m:
		continue
	m = re.match('^\s*<.*throw this exception.*>\s*$', line)
	if m:
		continue
	m = re.match('^(\s*<.*>)\s*$', line)
	if m:
		print m.group(1)

print "</ProfilingCollection>"
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to