computer-architecture

Where are variables in C++ stored?

谁都会走 提交于 2019-11-27 02:16:17
问题 Where are variables in C++ stored? Inside the RAM or the processor's cache? 回答1: Variables are stored: on the stack, if they're auto -matic function-local variables on the heap, if they're allocated with new or malloc , etc. (details of what it means to say "a variable is stored in the heap" in the comments) in a per-process data area if they are global or static This is all in RAM, of course. Caching is transparent to userspace processes, though it may visibily affect performance. Compilers

How do x86 page tables work?

為{幸葍}努か 提交于 2019-11-27 00:23:42
问题 I'm familiar with the MIPS architecture, which is has a software-managed TLB. So how and where you (the operating system) wants to store the page tables and the page table entries is completely up to you. For example I did a project with a single inverted page table; I saw others using 2-level page tables per process. But what's the story with x86? From what I know the TLB is hardware-managed. Does x86 tell basically tell you, "Hey this is where the page table entries you're currently using

What are stalled-cycles-frontend and stalled-cycles-backend in 'perf stat' result?

风流意气都作罢 提交于 2019-11-27 00:01:28
问题 Does anybody know what is the meaning of stalled-cycles-frontend and stalled-cycles-backend in perf stat result ? I searched on the internet but did not find the answer. Thanks $ sudo perf stat ls Performance counter stats for 'ls': 0.602144 task-clock # 0.762 CPUs utilized 0 context-switches # 0.000 K/sec 0 CPU-migrations # 0.000 K/sec 236 page-faults # 0.392 M/sec 768956 cycles # 1.277 GHz 962999 stalled-cycles-frontend # 125.23% frontend cycles idle 634360 stalled-cycles-backend # 82.50%

CPU Switches from User mode to Kernel Mode : What exactly does it do? How does it makes this transition?

谁说我不能喝 提交于 2019-11-26 22:48:38
问题 CPU Switches from User mode to Kernel Mode : What exactly does it do? How does it makes this transition? EDIT: Even if it is architecture dependent please provide me with an answer. The architecture is up to you. Tell me for the architecture you know about. I want to get an idea about what all things will be involved in it. 回答1: Note: this is mostly relevant to x86 architecture. Here's a somewhat simplified explanation. The transition is usually caused by one of the following: Fault (e.g. a

When an interrupt occurs, what happens to instructions in the pipeline?

做~自己de王妃 提交于 2019-11-26 17:35:06
Assume a 5 stage pipeline architecture (IF = Instruction Fetch, ID = Instruction Decode, EX = Execute, MEM = Memory access, WB = Register write back).There are 4 instructions that has to be executed. (These sample instruction are not accurate, but I believe the point would be understood) In the fifth clock cycle, these instruction will be in pipeline as shown below. Add a, b, c [IF ID EX MEM WB] Add a, b, d [IF ID EX MEM] Add a, b, e [IF ID EX] Add a, b, f [IF ID] Now if an hardware interrupts occur what happens to these instructions. Will the interrupt be handled only after all the

Line size of L1 and L2 caches

一曲冷凌霜 提交于 2019-11-26 17:06:28
From a previous question on this forum, I learned that in most of the memory systems, L1 cache is a subset of the L2 cache means any entry removed from L2 is also removed from L1. So now my question is how do I determine a corresponding entry in L1 cache for an entry in the L2 cache. The only information stored in the L2 entry is the tag information. Based on this tag information, if I re-create the addr it may span multiple lines in the L1 cache if the line-sizes of L1 and L2 cache are not same. Does the architecture really bother about flushing both the lines or it just maintains L1 and L2

maximum memory which malloc can allocate

喜你入骨 提交于 2019-11-26 14:28:59
I was trying to figure out how much memory I can malloc to maximum extent on my machine (1 Gb RAM 160 Gb HD Windows platform). I read that the maximum memory malloc can allocate is limited to physical memory (on heap). Also when a program exceeds consumption of memory to a certain level, the computer stops working because other applications do not get enough memory that they require. So to confirm, I wrote a small program in C: int main(){ int *p; while(1){ p=(int *)malloc(4); if(!p)break; } } I was hoping that there would be a time when memory allocation would fail and the loop would break,

What happens when a computer program runs?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 12:33:50
问题 I know the general theory but I can\'t fit in the details. I know that a program resides in the secondary memory of a computer. Once the program begins execution it is entirely copied to the RAM. Then the processor retrive a few instructions (it depends on the size of the bus) at a time, puts them in registers and executes them. I also know that a computer program uses two kinds of memory: stack and heap, which are also part of the primary memory of the computer. The stack is used for non

When an interrupt occurs, what happens to instructions in the pipeline?

前提是你 提交于 2019-11-26 05:30:16
问题 Assume a 5 stage pipeline architecture (IF = Instruction Fetch, ID = Instruction Decode, EX = Execute, MEM = Memory access, WB = Register write back).There are 4 instructions that has to be executed. (These sample instruction are not accurate, but I believe the point would be understood) In the fifth clock cycle, these instruction will be in pipeline as shown below. Add a, b, c [IF ID EX MEM WB] Add a, b, d [IF ID EX MEM] Add a, b, e [IF ID EX] Add a, b, f [IF ID] Now if an hardware

Line size of L1 and L2 caches

筅森魡賤 提交于 2019-11-26 05:00:21
问题 From a previous question on this forum, I learned that in most of the memory systems, L1 cache is a subset of the L2 cache means any entry removed from L2 is also removed from L1. So now my question is how do I determine a corresponding entry in L1 cache for an entry in the L2 cache. The only information stored in the L2 entry is the tag information. Based on this tag information, if I re-create the addr it may span multiple lines in the L1 cache if the line-sizes of L1 and L2 cache are not