- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was wondering how to send a specific instruction to one core in a dual-core CPU. For example, I want to read the thermal status of the second core. I can't find out how to send a rdmsr instruction to the second core.
Is there another way by which I am supposed to be able to retrieve the temperature from the DTS (digital temperature sensor) of one core?
Is there another way by which I am supposed to be able to retrieve the temperature from the DTS (digital temperature sensor) of one core?
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A common way of doing this is to create a thread that is forced to run on the target core. If using Windows, for example, look at the SetThreadAffinityMask() function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. I had thought of setting affinity but wasn't sure whether or not the RDMSR would just be sent to the first core anyway. So I will get the temperature of the second core by sending IA32_THERM_STATUS on a thread that's bound to the second core? Or are you not certain of that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've not tested it, but I believe that is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if you are on Linux, you can write a kernel module with the following:
int temperature[NR_CPUS];
void get_temp(int cpu)
{
int this_cpu = smp_processor_id();
if(this_cpu == cpu)
__temp_read(NULL);
else
smp_call_function_single(cpu,__temp_read,NULL,1,1);
return temperature[cpu];
}
void __temp_read(void *info)
{
u32 low,high;
int cpu = get_cpu();
rdmsr(IA32_THERM_STATUS,low,high)
temperature[cpu] = low | MASK; // get temp
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - prasadae
if you are on Linux, you can write a kernel module with the following: int temperature[NR_CPUS]; void get_temp(int cpu) { int this_cpu = smp_processor_id(); if(this_cpu == cpu) __temp_read(NULL); else smp_call_function_single(cpu,__temp_read,NULL,1,1); return temperature[cpu]; } void __temp_read(void *info) { u32 low,high; int cpu = get_cpu(); rdmsr(IA32_THERM_STATUS,low,high) temperature[cpu] = low | MASK; // get temp }
Or just use Linux NUMA API:
http://linux.die.net/man/3/numa_run_on_node
numa_run_on_node_mask() runs the current thread and its children only on nodes specified in nodemask. They will not migrate to CPUs of other nodes until the node affinity is reset with a new call to numa_run_on_node_mask(). Passing numa_all_nodes permits the kernel to schedule on all nodes again.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page