context switch vs memory access, which is faster? [closed] - cpu

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Got asked in an interview. They asked to order the following in terms of speed:
CPU register access,
Context switch
Memory access
Disk seek.
pretty sure the disk seek is the slowest and register access is the fastest, but not quite sure about the two in between. Can anyone explain it a bit?

I happened to find a surprisingly good answer on Yahoo!:
Fastest to slowest:
CPU
Memory
Context switching
Disk
Although:
Disk access may be significantly faster at times due to caching ... so
can memory access (CPUs sometimes manage a caches from main memory to
help speed up access and avoid competition for the bus).
Memory access could also be as slow or slightly slower than disk
access at times, due to virtual memory page swapping.
Context switching needs to be extremely fast in general ... if it was
slow then your CPU could begin to spend more time switching between
processes than actually performing meaningful work when several
processes are running concurrently.
Register access is nearly instantaneous.
(emphasis mine)
I agree with that answer.

Related

How to improve performance of PC, upgrade processor, memory or clock speed? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
A PC has a microprocessor which processes 16 instructions per microsecond. Each instruction is 64 bits long. Its memory can retrieve or store
data/instructions at a rate of 32 bits per microsecond.
Mention 3 options to upgrade system performance. Which option gives most improved performance?
And the answer provided is
a) upgrade processor to one with twice the speed
b) upgrade memory with one twice the speed
c) double clock speed
(b) gives most improved performance.
Overcoming the bottleneck of a PC can improve the integrated performance.
However, my problem is that I am not sure of why b gives the most improved performance. Additionally, would a and c give the same performance? Will it provide the same performance? Can it be calculated? I am not sure of how these different parts would work on the performance.
Your question's leading paragraph contains the necessary numbers to see why it's b):
The CPU's processing rate is fixed at 16 instructions per microsecond. So an instruction takes less than a microsecond to execute.
Each instruction is 64 bits long, but the memory system retrieves data at 32 bits per microsecond. So it takes two microseconds to retrieve a single instruction (i.e. 64 bits).
The bottleneck is clear: it takes longer to retrieve an instruction (2μs) than it does to execute it (1/16thμs).
If you increase the CPU speed (answer a)), the CPU will execute an individual instruction faster, but it will still be waiting idle at least 2μs for the next instruction to arrive, so the improvement is wasted.
To eliminate bottlenecks you need to increase the memory-system's speed to match the CPU's execution speed, so the memory needs to read 64 bits in a 1/16μs (or 32 bits in 1/32μs).
I assume answer c) refers to increasing the speed of some systemwide master clock which would also increase the CPU and Memory data-rates. This would improve performance, but the CPU would still be slaved to the memory speed.
Note that your question describes a simplistic computer. Computers were like this originally, where the CPU accessed memory directly, instruction-by-instruction. However as CPUs got faster, memory did not - so computer-engineers added cache levels: this is much faster memory (but much smaller in capacity) where instructions (and data memory) can be read as fast as a CPU can execute them, solving the bottleneck without needing to make all system memory match the CPU's speed.

What are the likely causes of the same program running significantly slower on only slightly different machines? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a mix of Dell machines, all bought at the same time, with only slightly different specs. The Windows Experience index is almost identical.
Yet my program runs at a speed difference of 25-40% (i.e. really noticeable) on the machines.
They are all out-of-the-box business Dells, no extra programs running (not that take up significant resources anyway).
My program is graphics-based, loading in a lot of data and then processing it on the CPU. CPU usage is identical on all machines, I only use a single thread.
I'd expect maybe 5-10% variation based on the processors (according to benchmarks).
My programmer spidey-sense tells me that something is wrong here.
Is this going to be something like cache misses? Is there anything else I should be looking at?
I have used debugging programs such as WinDbg for these situations. There are a lot of tools in those programs to nail down where the exact bottleneck is. E.g. Run them side by side and identify which point the slower machine is lagging. If physical specs of the machines are identical, it is most likely some difference in network configuration if there is a bottleneck when it is downloading the graphics. In that case, a tool such as WireShark would show you what hops the application is taking over the network to retrieve the data. If netwrok configuration is identical, I wouldn't rule out a physcial problem with the machine such as faulty ram or dodgy network cable. Also, check out the running processes side by side and see if there is any difference, kill unnessessary tasks that may be taking up memory on the slower computer and remove if necessary.

Workingset/privateWorkingSet memory don't add up to memory usage in Task manager [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Memory Issue
One of our server boxes shows 96% memory usage in task manager (137/140GB or so used).
When I look in the "Processes" tab though (even with show processes from all users checked), the top processes combined only use 40GB or so combined at peak times. I've provided an image of top used processes below as well as an image of the performance panel showing the memory usage.
Note: CPU usage isn't usually at 99%, it spiked when I took that screenshot.
My Question
What is the reason for this discrepancy, and how can I more accurately tell which processes are eating the other 100GB of memory?
To verify, here's an image of the performance pannel:
Sergmat is correct in his comment (thanks by the way); I actually found RAMMAP myself yesterday and used it and it revealed the problem.
Our server runs a very heavily used SQL Server instance. RAMMAP reveals that there is a 105GB region of memory used for "AWE" Address Windowing Extensions - which are used to manipulate large regions of memory very quickly by things like RDBMS's (SQL Server).
Apparently you can configure the maximum memory SQL Server would use, this being included; so that's the solution.

where does OSs keep the programs that are not used for some minutes? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Typically in a working environment, I have many windows open, Outlook, 2/3 word docuements, few windows in browser, notepad++, some vpn client, excel etc..
Having said that, there are chances that about 40% of these apps are not frequently used, but are referred only sparingly. They occupy memory none-the-less.
Now, how does a typical OS deal with that kind of memory consumption ? does it suspend that app to hard disk (pagefile , or linux swap area etc) thereby freeing up that memory for usage, or does it keep occupying the memory there as it is.
Can this suspension be a practical solution, doable thing ? Are there any downsides ? response time ?
Is there some study material I can refer to for reading on this topic/direction..
would appreciate the help here.
The detailed answer depends on your OS and how it implements its memory management, but here is a generality:
The OS doesnt look at memory in terms of how many processes are in RAM, it looks at in terms of discrete units called pages. Most processes have several pages of RAM. Pages that are least referenced can be swapped out of RAM and onto the hard disk when physical RAM becomes scarce. Rarely, therefore, is an entire process swapped out of RAM, but only certain parts of it. It could be, for example, that some aspect of your currently running program is idle (ie the page is rarely accessed). In that case, it could be swapped out even though the process is in the foreground.
Try the wiki article for starters on how this process works and the many methods to implement it.

Why isn't RAM as fast as registers/cache memory? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Why do we need to cache in Cache Memory? Why cant RAM Memory be made as fast as register or Cache Memory or Cache be as large as RAM Memory (4GB) so that everything can be in cache? Any good article/books to understand these concepts?
Faster stuff costs more per bit. So you have a descending chain of storage, from a few registers at one end, through several levels of cache, down to RAM. Each level is bigger and slower than the one before. And all the way at the bottom you have disk.
Registers and cache are on the cpu chip itself, or tied to it very closely. Normal RAM is accessed through an address bus, and it often subject to a level of indirection by memory mapping.

Resources