cpu

How does a single CPU handle Multi-threaded and multi-process applications?

我的未来我决定 提交于 2019-11-29 12:25:37
问题 As I have read that for a multi-process application, a single CPU can handle only one task at a time, switching contexts between two processes. In a multi-threaded application, a single CPU can handle multiple threads. I do not understand this. Does the CPU handle one thread at a time if there is only one CPU? If yes, where is the advantage of having multi-threaded application vs multi-process application if CPU can handle one thing at a time. 回答1: TL;DR Multithreading on a single core can

How do you detect the CPU architecture type during run-time with GCC and inline asm?

99封情书 提交于 2019-11-29 12:18:34
I need to find the architecture type of a CPU. I do not have access to /proc/cpuinfo, as the machine is running syslinux. I know there is a way to do it with inline ASM, however I believe my syntax is incorrect as my variable iedx is not being set properly. I'm drudging along with ASM, and by no means an expert. If anyone has any tips or can point me in the right direction, I would be much obliged. static int is64Bit(void) { int iedx = 0; asm("mov %eax, 0x80000001"); asm("cpuid"); asm("mov %0, %%eax" : : "a" (iedx)); if ((iedx) && (1 << 29)) { return 1; } return 0; } tyranid How many bugs can

Profiled app with YourKit, still can't identify the CPU hog

放肆的年华 提交于 2019-11-29 11:40:29
I've got a Java application that is consuming 100% of the CPU most of the time (as indicated by cacti and top monitoring). We fired up YourKit (which confirms the CPU resource issue) and it identifies java.net.SocketInputStream.read(byte[], int, int) as the biggest hot spot at 15% of time. I believe they aren't accurately measuring CPU time for methods that perform blocking IO like SocketInputStream.read would. There are 6 other identified hot spots, but they account for less than 20% of accounted for CPU time combined. all in the 5%-1% range. So I know I have a problem, I can see the problem,

What has a better performance: multiplication or division?

我的未来我决定 提交于 2019-11-29 11:22:33
Which version is faster ? x * 0.5 or x / 2 Ive had a course at the university called computer systems some time ago. From back then i remember that multiplying two values can be achieved with comparably "simple" logical gates but division is not a "native" operation and requires a sum register that is in a loop increased by the divisor and compared to the dividend. Now i have to optimise an algorithm with a lot of divisions. Unfortunately its not just dividing by two so binary shifting is no option. Will it make a difference to change all divisions to multiplications ? update: I have changed

Is there hardware support for 128bit integers in modern processors?

六眼飞鱼酱① 提交于 2019-11-29 09:24:04
Do we still need to emulate 128bit integers in software, or is there hardware support for them in your average desktop processor these days? Z boson The x86-64 instruction set can do 64-bit*64-bit to 128-bit using one instruction ( mul for unsigned imul for signed each with one operand) so I would argue that to some degree that the x86 instruction set does include some support for 128-bit integers. If your instruction set does not have an instruction to do 64-bit*64-bit to 128-bit then you need several instructions to emulate this . This is why 128-bit * 128-bit to lower 128-bit operations can

Is there a way to check whether the processor cache has been flushed recently?

[亡魂溺海] 提交于 2019-11-29 08:28:17
问题 On i386 linux. Preferably in c/(c/posix std libs)/proc if possible. If not is there any piece of assembly or third party library that can do this? Edit: I'm trying to develop test whether a kernel module clear a cache line or the whole proccesor(with wbinvd()). Program runs as root but I'd prefer to stay in user space if possible. 回答1: Cache coherent systems do their utmost to hide such things from you. I think you will have to observe it indirectly, either by using performance counting

Background threads consuming 100% CPU on iPhone 3GS causes latent main thread

寵の児 提交于 2019-11-29 08:28:15
问题 In my application I am executing 10 asynchronous NSURLConnections within an NSOperationQueue as NSInvocationOperations. In order to prevent each operation from returning before the connection has had a chance to finish I call CFRunLoopRun() as seen here: - (void)connectInBackground:(NSURLRequest*)URLRequest { TTURLConnection* connection = [[TTURLConnection alloc] initWithRequest:URLRequest delegate:self]; // Prevent the thread from exiting while the asynchronous connection completes the work.

Retrieve system information on MacOS X? [closed]

被刻印的时光 ゝ 提交于 2019-11-29 08:10:26
Using C++ is there anyway I could get basic information about the computer? For example is there a way I could check how much memory is being used (by the whole computer not just my computer), the total memory available, virtual memory usage, CPU usage, networks stats and so on? I am using Mac OS X Snow Leopard but I would prefer a solution that could be implemented for all Mac OSs (i.e. Lion) Jeremy Friesner For system-wide memory usage information under MacOS/X, open and read the file /usr/bin/vm_stat, something like this: static double ParseMemValue(const char * b) { while((*b)&&(isdigit(*b

How to compute the theoretical peak performance of CPU

本小妞迷上赌 提交于 2019-11-29 06:43:47
问题 Here is my cat /proc/cpuinfo output: ... processor : 15 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Xeon(R) CPU E5520 @ 2.27GHz stepping : 5 cpu MHz : 1600.000 cache size : 8192 KB physical id : 1 siblings : 8 core id : 3 cpu cores : 4 apicid : 23 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic ... bogomips : 4533.56 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual

Python multiprocessing.cpu_count() returns '1' on 4-core Nvidia Jetson TK1

一个人想着一个人 提交于 2019-11-29 06:39:54
Can anyone tell me why Python's multiprocessing.cpu_count() function would return 1 when when called on a Jetson TK1 with four ARMv7 processors? >>> import multiprocessing >>> multiprocessing.cpu_count() 1 The Jetson TK1 board is more or less straight out of the box, and no one has messed with cpusets. From within the same Python shell I can print the contents of /proc/self/status and it tells me that the process should have access to all four cores: >>> print open('/proc/self/status').read() ----- (snip) ----- Cpus_allowed: f Cpus_allowed_list: 0-3 ----- (snip) ----- What else could be