cpu

Can a C# program measure its own CPU usage somehow?

浪尽此生 提交于 2019-12-17 21:46:59
问题 I am working on a background program that will be running for a long time, and I have a external logging program (SmartInspect) that I want to feed with some values periodically, to monitor it in realtime when debugging. I know I can simply fire up multiple programs, like the Task Manager, or IARSN TaskInfo, but I'd like to keep everything in my own program for this, as I also wants to add some simple rules like if the program uses more than X% CPU, flag this in the log. I have a background

Profiling CPU Cache/Memory from the OS/Application?

青春壹個敷衍的年華 提交于 2019-12-17 19:43:04
问题 I wish to write software which could essentially profile the CPU cache (L2,L3, possibly L1) and the memory, to analyze performance. Am I right in thinking this is un-doable because there is no access for the software to the cache content? Another way of wording my Q: is there any way to know, from the OS/Application level, what data has been loaded into cache/memory? EDIT: Operating System Windows or Linux and CPU Intel Desktop/Xeon 回答1: You might want to look at Intel's PMU i.e. Performance

MultiCore CPUs, Multithreading and context switching?

▼魔方 西西 提交于 2019-12-17 19:20:00
问题 Let's say we have a CPU with 20 cores and a process with 20 CPU-intensive independent of each other threads: One thread per CPU core. I'm trying to figure out whether context switching happens in this case. I believe it happens because there are system processes in the operating system that need CPU-time too. I understand that there are different CPU architectures and some answers may vary but can you please explain: How context switching happens e.g. on Linux or Windows and some known CPU

Set thread processor affinity in Microsoft .Net

两盒软妹~` 提交于 2019-12-17 18:43:08
问题 (Posting this with answer because I couldn't find a full explanation of how to do this anywhere, so I thought it might have some value for someone) How can I set the processor affinity of a particular thread in Microsoft .Net? Setting the process's affinity is trivial via System.Diagnostics.Process.ProcessorAffinity, but the System.Threading.Thread class offers no such functionality and .Net doesn't guarantee a managed thread is linked to any particular operating system thread. 回答1: The

How many bits are in the address field for a directly mapped cache?

亡梦爱人 提交于 2019-12-17 17:28:10
问题 This is a question based on Direct Mapped Cache so I am assuming that it's ok to ask here as well. Here is the problem I am working on: The Problem: " A high speed workstation has 64 bit words and 64 bit addresses with address resolution at the byte level. Assuming a direct mapped cache with 8192 64 byte lines, how many bits are in each of the following address fields for the cache? 1) byte 2) Index 3) Tag?" First I defined the terms in this problem and used the other Stack Overflow Direct

x86 registers: MBR/MDR and instruction registers

我只是一个虾纸丫 提交于 2019-12-17 16:42:10
问题 From what I have read, the IA-32 architecture has ten 32-bit and six 16-bit registers. The 32-bit registers are as follows: Data registers - EAX, EBX, ECX, EDX Pointer registers - EIP, ESP, EBP Index registers - ESI, EDI Control registers - EFLAG (EIP is also classified as a control register) The 16-bit registers are as below: Code Segment: It contains all the instructions to be executed. Data Segment: It contains data, constants and work areas. Stack Segment: It contains data and return

How instructions are differentiated from data?

左心房为你撑大大i 提交于 2019-12-17 15:56:35
问题 While reading ARM core document, I got this doubt. How does the CPU differentiate the read data from data bus, whether to execute it as an instruction or as a data that it can operate upon? Refer to the excerpt from the document - "Data enters the processor core through the Data bus. The data may be an instruction to execute or a data item." Thanks in advance for enlightening me! /MS 回答1: Each opcode will consist of an instruction of N bytes, which then expects the subsequent M bytes to be

Getting CPU temperature using Python? [closed]

帅比萌擦擦* 提交于 2019-12-17 15:54:31
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . How do I retrieve the temperature of my CPU using Python? (Assuming I'm on Linux) 回答1: Py-cputemp seems to do the job. 回答2: There is a newer "sysfs thermal zone" API (see also LWN article and Linux kernel doc) showing temperatures under e.g. /sys/class/thermal/thermal_zone0/temp

prefetching data at L1 and L2

折月煮酒 提交于 2019-12-17 15:46:28
问题 In Agner Fog's manual Optimizing software in C++ in section 9.10 "Cahce contentions in large data structures" he describes a problem transposing a matrix when the matrix width is equal to something called the critical stride. In his test the cost for for a matrix in L1 is 40% greater when the width is equal to the critical stride. If the matrix is is even larger and only fits in L2 the cost is 600%! This is summed up nicely in Table 9.1 in his text. This is essential the same thing observed

CPUID implementations in C++

偶尔善良 提交于 2019-12-17 15:28:53
问题 I would like to know if somebody around here has some good examples of a C++ CPUID implementation that can be referenced from any of the managed .net languages. Also, should this not be the case, should I be aware of certain implementation differences between X86 and X64? I would like to use CPUID to get info on the machine my software is running on (crashreporting etc...) and I want to keep everything as widely compatible as possible. Primary reason I ask is because I am a total noob when it