cpu

I/O bound and CPU bound

岁酱吖の 提交于 2019-11-30 22:53:52
Hei. I'm using Node.JS with child_process to spawn bash processes. I'm trying to understand if i'm doing I/O bound, CPU bound or both. I'm using pdftotext to extract the text of 10k+ files. To control concurrences, I'm using async . Code: let spawn = require('child_process').spawn; let async = require('async'); let files = [ { path: 'path_for_file' ... }, ... ]; let maxNumber = 5; async.mapLimit(files, maxNumber, (file, callback) => { let process = child_process.spawn('pdftotext', [ "-layout", "-enc", "UTF-8", file.path, "-" ]); let result = ''; let error = ''; process.stdout.on('data',

How are shifts implemented on the hardware level?

我与影子孤独终老i 提交于 2019-11-30 22:48:01
问题 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? 回答1: The circuit is called a "barrel shifter" - it's a load of

How is code stored in the EXE format?

萝らか妹 提交于 2019-11-30 21:35:12
My questions are as follows: How does the Portable Executable format (on windows/unix) relate to the x86/x64 instruction set in general? Does the PE format store the exact set of opcodes supported by the processor, or is it a more generic format that the OS converts to match the CPU? How does the EXE file indicate the instruction set extensions needed (like 3DNOW! or SSE/MMX?) Are the opcodes common across all platforms like Windows, Mac and unix? Intel i386 compatible CPU chips like ones from Intel and AMD use a common instruction set. But I'm sure ARM-powered CPUs use different opcodes. Are

How can i stress my phone's CPU programatically?

若如初见. 提交于 2019-11-30 20:41:01
So i overclocked my phone to 1.664ghz and I know there are apps that test your phone's CPU performance and stressers but I would like to make my own someway. What is the best way to really make your CPU work? I was thinking just making a for loop do 1 million iterations of doing some time-consuming math...but that did not work becuase my phone did it in a few milliseconds i think...i tried trillions of iterations...the app froze but my task manager did not show the cpu even being used by the app. Usually stress test apps show up as red and say cpu:85% ram: 10mb ...So how can i really make my

How to get usage of each cpu core on android

拟墨画扇 提交于 2019-11-30 20:30:10
问题 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

Are two consequent CPU stores on x86 flushed to the cache keeping the order?

萝らか妹 提交于 2019-11-30 20:27:04
Assume there are two threads running on x86 CPU0 and CPU1 respectively. Thread running on CPU0 executes the following commands: A=1 B=1 Cache line containing A initially owned by CPU1 and that containing B owned by CPU0. I have two questions: If I understand correctly, both stores will be put into CPU’s store buffer. However, for the first store A=1 the cache of CPU1 must be invalidated while the second store B=1 can be flushed immediately since CPU0 owns the cache line containing it. I know that x86 CPU respects store orders. Does that mean that B=1 will not be written to the cache before A=1

How to get CPU utilization in % in terminal (mac)

强颜欢笑 提交于 2019-11-30 20:12:47
Ive seen the same question asked on linux and windows but not mac (terminal). Can anyone tell me how to get the current processor utilization in %, so an example output would be 40% . Thanks This works on a Mac (includes the %): ps -A -o %cpu | awk '{s+=$1} END {print s "%"}' To break this down a bit: ps is the process status tool. Most *nix like operating systems support it. There are a few flags we want to pass to it: -A means all processes, not just the ones running as you. -o lets us specify the output we want. In this case, it all we want to the cpu% column of ps 's output. This will get

branch prediction vs branch target prediction

邮差的信 提交于 2019-11-30 19:09:43
Have I understood this right, if statements are more dependent on branch prediction and v-table look-up is more dependent on branch target prediction? Regarding v-tables, there is no "branch prediction", just the target prediction? Trying to understand how a v-table is processed by the CPU. Branch prediction is predicting whether or not the branch will be taken . Branch target prediction is prediction where the branch is going to. These two things are independent and can occur in all combinations. Examples of these might be: Unconditional branch, fixed target Infinite loop goto statement break

How is it possible to read the CPU registers using a debugger running on the same CPU?

假如想象 提交于 2019-11-30 18:32:50
As I was learning about assembly, I used GDB the following way: gdb ./a.out (a is a compiled C script that only prints hello world) break main run info registers Why can I see the registers used by my program when I am myself using the same CPU to print the registers? Shouldn't the use of GDB (or operating system) overwrite the registers and only show me the overwritten registers? The only answer I can think of is the fact that my CPU is dual-core and that one of the cores is being used and the other is kept for the program. The operating system maintains the state of the registers for each

I/O bound and CPU bound

拜拜、爱过 提交于 2019-11-30 18:01:08
问题 Hei. I'm using Node.JS with child_process to spawn bash processes. I'm trying to understand if i'm doing I/O bound, CPU bound or both. I'm using pdftotext to extract the text of 10k+ files. To control concurrences, I'm using async. Code: let spawn = require('child_process').spawn; let async = require('async'); let files = [ { path: 'path_for_file' ... }, ... ]; let maxNumber = 5; async.mapLimit(files, maxNumber, (file, callback) => { let process = child_process.spawn('pdftotext', [ "-layout",