Unfortunately the kernel does not have a way of finding all the TCBs that have been created in the system. You would have to manipulate the TCB creation/deletion code to maintain a linked list of all the created TCBs.

To call raw system calls just make sure you #include <sel4/sel4.h> and then yes, you can just directly call them from any component code.

Adrian

On Wed 18-Jan-2017 1:10 PM, Andrew Gacek wrote:
Actually, is there any easy way to get all TCBs even from within the
kernel? I see ksReadyQueues has all the runnable TCBs, but what about
the rest?

-Andrew

On Tue, Jan 17, 2017 at 7:29 PM, Andrew Gacek <andrew.gacek@gmail.com> wrote:
Thanks Adrian. This is a useful start. It sounds like the easiest
thing may be to overwrite some syscall that I don't use to loop over
all the threads in the kernel and print out their debugging info.

Also, I've never called raw seL4 system calls from a camkes component
before. Is it just a matter of calling seL4_BenchmarkResetLog() or
seL4_BenchmarkFinalizeLog() directly in the control code for one of my
components?

-Andrew

On Tue, Jan 17, 2017 at 7:23 PM,  <Adrian.Danis@data61.csiro.au> wrote:
Hi Andrew,

There is some code already in the kernel to help you do this, although it is
tested and fixed on an as used basis so may or may not work as I describe.
You can enable the the thread utilization tracking with
make menuconfig -> seL4 Kernel -> Build Options -> Enable benchmarks ->
Track threads and kernel utilisation time
Once enabled you gain the following relevant functions

seL4_BenchmarkResetLog()
Reset idle time and total run time and start capturing utilization
information

seL4_BenchmarkFinalizeLog()
Calculate idle time, total run time and stop capturing utilization
information

seL4_BenchmarkGetThreadUtilisation(seL4_Word tcb_cptr)
Retrieve the utilization for a particular thread where
seL4_GetMR(0) == Thread utilization (in cycles) of this (tcb_cptr) thread
seL4_GetMR(1) == Idle thread utilization (in cycles) between the last call
to Reset and Finalize log
seL4_GetMR(2) == Totall execution time (in cycles) between the last call to
Reset and Finalize log

seL4_BenchmarkResetThreadUtilisation(seL4_Word tcb_cptr)
Reset the utilization of this thread.

The main problem with this API is that it requires you to have caps to all
the threads you wish to get the information of, which in CAmkES is generally
only the capdl-loader application. It is also designed with the idea that
you want to reset the utilization counts at the point you're querying them,
i.e. you're doing some kind of benchmark and you just want utilization over
that benchmark.

Hope this provides some use to you.

Adrian


On Wed 18-Jan-2017 9:59 AM, Andrew Gacek wrote:

Hi,

I'm interested in seeing how much of the CPU is being used by the
various threads in my (camkes) application. I'd like a simple "Task
Manager" style report of the form:

70% idle
25% can_obj_7_0_control_9_tcb
5% can_obj_7_Int_3_0000_tcb
0% can_obj_7_0_fault_handler_15_
0000_tcb
etc

I've tried poking around libsel4bench, but I don't see any obvious way
of benchmarking the whole system. From what I can tell, it's mostly
designed to get cycle counts from specific code segments. Is that
right? What's the best way to go about benchmarking the whole system?
It's only for debugging, so I'm willing to make some quick-and-dirty
changes to the kernel just to see the results.

Thanks,
Andrew

_______________________________________________
Devel mailing list
Devel@sel4.systems
https://sel4.systems/lists/listinfo/devel