Friday, March 25, 2005

Windows Virtual Memory

In light of a big project with Microsoft, I started to collect Windows OS resources. Wong's article is definitely a must-read for anyone interested with Windows virtual memory management.

Think you are pretty clear with Microsoft's VM?

Question: what is the difference between a swap file and a page file?

The differences lie in how the process is being swapped and how the free space is being used by other processes.

Thursday, March 24, 2005

Read-Copy Update Mutex in Linux Kernel

I ran into a nice article talking about Read-Copy Update at LSE sourceforge site (Linux Scalability Effort). RCP differs from traidational spin-lock mutex (spin-waiting) in that:
Read-Copy Update is one ... mutual exclusion method where readers (threads trying to access, but not modify the data) can access the shared data without acquiring any conventional lock. The writers (threads that update the data) however, have to use a special callback scheme to update the data. They update all the global references to the updated data with a new copy and use the callback scheme to free the old copy after all the CPUs have lost local references to it by going through a quiescent state (like a context switch).
The overhead of spin waiting could be high when multiple threads are accessing the same route cache or routing table, for example. As you can see, the "write" is more expensive because it has to make sure processors have lost reference to the old data. The implementation can be downloaded here.

As a sidenote, semaphores in Linux are sleeping locks as opposed to spnning locks. So semaphores should be used when lock-held time is long considering the overhead of putting thread in sleep and waking it up later.

At this point(03/24/2005), the latest kernel may have already incorporated this scheme or even better scheme to replace spin locks. I will check it out when I get a chance.