In the WhiteBoxImpl.cpp there is a function get_thread_t(aCPU). This function returns the thread_t pointer of the cpu struct. Actually there is a cpu list in the kernel. There is an offset to find the next cpu in the list. Then inside the cpu struct there is a pointer in a thread_t struct where you can find the thread id.
The numbers 0x10, 0x48 are hardcoded for Solaris 8. You can look in Open solaris source code to see what is true for Solaris 10 http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/sys/cpuvar.h#cpu_t You will also need to find the virtual address of the cpu_list in the kernel. You can use the kernel debugger (kdb). Regards, -Stavros ________________________________ From: mihai pricopi [[email protected]] Sent: Wednesday, July 28, 2010 12:44 PM To: Volos Stavros Cc: [email protected] Subject: Re: Get values per thread Hello, I`m trying to understand how the white box is working. I see this code where I suppose I have to find the answer: struct WhiteBoxImpl : WhiteBox { API::symtable_interface_t * theSymTable; std::vector< PhysicalMemoryAddress > theThreadTs; std::vector< PhysicalMemoryAddress > theIdleThreadTs; WhiteBoxImpl() { #if FLEXUS_TARGET_IS(v9) API::SIM_load_module("symtable"); API::conf_class_t * symtable_class = API::SIM_get_class("symtable"); API::conf_object_t * symtable_obj = API::SIM_new_object(symtable_class, "flexus_symtable"); theSymTable = reinterpret_cast<API::symtable_interface_t *>(API::SIM_get_class_interface(symtable_class, "symtable")); for (int32_t i = 0; i < API::SIM_number_processors(); ++i) { API::conf_object_t * ctx = API::SIM_get_attribute(Simics::APIFwd::SIM_get_processor(i), "current_context").u.object; API::attr_value_t val; val.kind = API::Sim_Val_Object; val.u.object = symtable_obj; API::SIM_set_attribute(ctx, "symtable", &val); } API::attr_value_t arch = API::SIM_get_attribute( Simics::APIFwd::SIM_get_processor(0), "architecture"); API::SIM_set_attribute( symtable_obj, "arch", &arch); DBG_(Dev, ( << "symtable loaded" ) ); #endif } The problem is that I don't know which thread is being executed because I suspect Solaris10 is doing the thread migration meanwhile and I can't rely on the values until I see per thread. Does the ctx hold the information about the current thread that the timing simulation is executing per core ? Thanks Mihai On Wed, Jul 28, 2010 at 4:22 AM, Volos Stavros <[email protected]<mailto:[email protected]>> wrote: Actually, the component WhiteBox is responsible to give the thread id of the thread that is being executed in a particular CPU. However, this component is hardcoded for Solaris 8. I worked on this component to support Solaris 10, but I didn't have time to check whether it works properly or not. Assuming that you know which thread is being executed, it should be easy to get measured values per software thread. Regards, -Stavros ________________________________ From: mihai pricopi [[email protected]<mailto:[email protected]>] Sent: Tuesday, July 27, 2010 6:07 PM To: Volos Stavros Subject: Re: Get values per thread Per software thread. I discovered that Solaris modifies a register when it does the context switch but I`m not sure where exactly in flexus i can read that register and if flexus already gives me this information ? Thanks On Tue, Jul 27, 2010 at 11:55 PM, Volos Stavros <[email protected]<mailto:[email protected]>> wrote: Hi Mihai, What do you mean by the term "thread"? Do you mean software thread or hardware thread (multithreaded processor) ? Regards, -Stavros ________________________________ From: mihai pricopi [[email protected]<mailto:[email protected]>] Sent: Tuesday, July 27, 2010 12:57 PM To: [email protected]<mailto:[email protected]> Subject: Get values per thread Hi, Is it possible that Flexus can give measured values per thread not per core ? Thanks
