cpu

How does the CPU knows which interrupt service routine to run against a hardware interrupt?

青春壹個敷衍的年華 提交于 2019-12-01 09:26:27
问题 For example, a key on a keyboard is press causing a hardware interrupt to be generated to the CPU, the CPU sends an acknowledgement to the interrupt controller. At the stage of the interrupt process, how does the CPU knows which interrupt service routine to run based on a key press on the keyboard? 来源: https://stackoverflow.com/questions/48110019/how-does-the-cpu-knows-which-interrupt-service-routine-to-run-against-a-hardware

Which instructions can not be issued in specific CPU ring

放肆的年华 提交于 2019-12-01 08:51:03
According to this source (Level 3 - 5) specific CPU rings can not do certain things, such as ring 1, 2, 3 code can not set up GDT, as os kernel would crash. While it is obvious that Ring 0 can execute all instructions, I am wondering which instructions can not be issued in rings 1, 2 and 3? I could not find anything on either wikipedia or osdev and similar sources which would state what instructions can not be issued in specific ring. The following instructions cannot be executed in Ring 3: LGDT LLDT LTR LIDT MOV (to and from control registers only) MOV (to and from debug registers only) LMSW

Which instructions can not be issued in specific CPU ring

天大地大妈咪最大 提交于 2019-12-01 06:46:18
问题 According to this source (Level 3 - 5) specific CPU rings can not do certain things, such as ring 1, 2, 3 code can not set up GDT, as os kernel would crash. While it is obvious that Ring 0 can execute all instructions, I am wondering which instructions can not be issued in rings 1, 2 and 3? I could not find anything on either wikipedia or osdev and similar sources which would state what instructions can not be issued in specific ring. 回答1: The following instructions cannot be executed in Ring

Calculating CPU frequency in C with RDTSC always returns 0

a 夏天 提交于 2019-12-01 06:43:41
The following piece of code was given to us from our instructor so we could measure some algorithms performance: #include <stdio.h> #include <unistd.h> static unsigned cyc_hi = 0, cyc_lo = 0; static void access_counter(unsigned *hi, unsigned *lo) { asm("rdtsc; movl %%edx,%0; movl %%eax,%1" : "=r" (*hi), "=r" (*lo) : /* No input */ : "%edx", "%eax"); } void start_counter() { access_counter(&cyc_hi, &cyc_lo); } double get_counter() { unsigned ncyc_hi, ncyc_lo, hi, lo, borrow; double result; access_counter(&ncyc_hi, &ncyc_lo); lo = ncyc_lo - cyc_lo; borrow = lo > ncyc_lo; hi = ncyc_hi - cyc_hi -

Calculating CPU frequency in C with RDTSC always returns 0

空扰寡人 提交于 2019-12-01 04:45:50
问题 The following piece of code was given to us from our instructor so we could measure some algorithms performance: #include <stdio.h> #include <unistd.h> static unsigned cyc_hi = 0, cyc_lo = 0; static void access_counter(unsigned *hi, unsigned *lo) { asm("rdtsc; movl %%edx,%0; movl %%eax,%1" : "=r" (*hi), "=r" (*lo) : /* No input */ : "%edx", "%eax"); } void start_counter() { access_counter(&cyc_hi, &cyc_lo); } double get_counter() { unsigned ncyc_hi, ncyc_lo, hi, lo, borrow; double result;

How are shifts implemented on the hardware level?

耗尽温柔 提交于 2019-12-01 02:56:48
How are bit shifts implemented at the hardware level when the number to shift by is unknown? I can't imagine that there would be a separate circuit for each number you can shift by (that would 64 shift circuits on a 64-bit machine), nor can I imagine that it would be a loop of shifts by one (that would take up to 64 shift cycles on a 64-bit machine). Is it some sort of compromise between the two or is there some clever trick? The circuit is called a " barrel shifter " - it's a load of multiplexers basically. It has a layer per address-bit-of-shift-required, so an 8-bit barrel shifter needs

How to get usage of each cpu core on android

十年热恋 提交于 2019-12-01 01:59:17
I develop a widget on Android which display many useful informations. I am trying to modify this method to return the percent of use of one cpu core, in order to have the percent of use of each core !!! On my HTC One X, i have in " /proc/stat ": cpu 183549 10728 236016 3754379 7530 41 1013 0 0 0 cpu0 141962 5990 196956 720894 3333 41 970 0 0 0 cpu1 23400 2550 23158 980901 2211 0 23 0 0 0 cpu2 13602 1637 12561 1019126 1216 0 18 0 0 0 cpu3 4585 551 3341 1033458 770 0 2 0 0 0 I use this method to return the percent of use of all cpu core. public float readUsage() { try { RandomAccessFile reader =

CPU Usage using WMI & C#

烈酒焚心 提交于 2019-12-01 01:14:58
How can i retrieve the current CPU usage in c# using WMI? I've seen plenty of posts using performance counters, but I need a solution that can work with remote machines. I've also found a VB solution here , but I'd prefer to accomplish this in C# if possible. Performance with WMI is messy, to say the least. Performance counters work OK with remote machines. Use the System.Diagnostics.PerformanceCounterXxx classes, the constructors have overloads which take a machineName argument. the tool "pslist" from sysinternals (its free) could readout the usage from remotemachines. y could start the

APIC multi-core startup Protocol and ICR starting up address

血红的双手。 提交于 2019-12-01 00:52:38
I am writing a boot load and try to test Inter-Processor Interrupt. I got the following 2 questions blocked me: 1, Where I can find the procedure of starting up APs; 2, When issuing IPI, where I should load the memory address to tell the target processor which memory address to start with. Thanks for answering, and if you could be so kind to attach a assembly example. Michael Petch I lifted this from the now defunct Stackoverflow Documentation project. This was originally written by Margaret Bloom and I had cleaned up her code. Since this was not my own, I have marked it community wiki. There

What core is a given thread running on?

故事扮演 提交于 2019-11-30 23:16:14
Is there a function or any other way to know, programatically, what core of what processor a given thread of my program (pid) is running on? Both OpenMP or Pthreads solutions would help me, if possible. Thanks. This is going to be platform-specific, I would think. On Windows you can use NtGetCurrentProcessorNumber , but this is caveat-ed as possibly disappearing. I expect this is hard to do, because there's nothing to stop the thread being moved to a new core at any time (in most apps, anyway). As soon as you get the result, it could be out of date. I think on Linux one can try sched_getcpu().