memory-access

Shared memory access permissions on Windows

I've developed a windows application that uses shared memory---that is---memory mapped files for interprocess communication. I have a windows service that does some processing and periodically writes data to the memory mapped file. I have a separate windows application that reads from the memory mapped file and displays the information...

How are variables on the stack accessed?

Suppose we have these local variables: int a = 0; int b = 1; int c = 2; int d = 3; As far as I know, these will be allocated on the system stack, like this: | | | 3 | d | 2 | c | 1 | b |_0_| a Does this mean that in order to get the value of a, the values of d, c and b must first be popped out of the stack? If so, where do these ...

What is the Cost of an L1 Cache Miss?

Edit: For reference purposes (if anyone stumbles across this question), Igor Ostrovsky wrote a great post about cache misses. It discusses several different issues and shows example numbers. End Edit I did some testing <long story goes here> and am wondering if a performance difference is due to memory cache misses. The following cod...

Memory (sbrk) 16-byte aligned shifting on pointer access

I wrote a reasonably basic memory allocator using sbrk. I ask for a chunk of memory, say 65k and carve it up as needed for variables requesting dynamic memory. I free the memory by adding it back to the 65k block. The 65k block is derived from a union sizeof(16-bytes). Then I align the block along an even 16-byte boundary. But I'm gettin...

Efficiency: arrays vs pointers

Memory access through pointers is said to be more efficient than memory access through an array. I am learning C and the above is stated in K&R. Specifically they say Any operation that can be achieved by array subscripting can also be done with pointers. The pointer version will in general be faster I dis-assembled the following ...

What happens if two threads read & write the same piece of memory

It's my understanding that if two threads are reading from the same piece of memory, and no thread is writing to that memory, then the operation is safe. However, I'm not sure what happens if one thread is reading and the other is writing. What would happen? Is the result undefined? Or would the read just be stale? If a stale read is not...

Is reading from remote networked memory mapped file or device block faster than reading from Local 7200rpm HDDs?

Or rather how does remote RAM compare against local Disk access? If the answer is "it depends", what are the conditions? Data access patterns, ratio of read-to-writes, distance etc. Finally, what if the local disks are NetApp filers? Thanks. ...

Can a single core saturate a CPU's memory IO bandwidth?

Assuming an ideal situation: nothing is paged out, all code is really well written and fits in cache, the scheduler never interrupts you, etc.: can a single core in a multi-core CPU generate enough write traffic to saturate the IO bus to the DIMMs? In a more concrete form: If I were to launch a program that does a 16GB memset in one thr...