0
$\begingroup$

I was going through the text of the book Computer Architecture: A Quantitative Approach. It has a section in Chapter 5 where it discusses the fact that OS code undergoes more cache misses as compared to user code. Here is the text:

Although the user code executes more instructions, the behavior of the operating system can cause more cache misses than the user processes for two reasons beyond larger code size and lack of locality. First, the kernel initializes all pages before allocating them to a user, which significantly increases the compulsory component of the kernel’s miss rate. Second, the kernel actually shares data and thus has a nontrivial coherence miss rate. In contrast, user processes cause coherence misses only when the process is scheduled on a different processor, and this component of the miss rate is small. This is a major difference between a multiprogrammed workload and one like the OLTP workload.

What is the first argument trying to explain? My doubt is that although the kernel has to initialize the pages for allocation to a user, it(the kernel) is not required to retrieve data from those pages into cache. That is the user code's responsibility. Hence, the argument seems confusing.

$\endgroup$
2
$\begingroup$

There's cache misses when you access a page for the first time, then you get hits. Since the kernel initialises the page, it gets all the cache misses. Then it passes the page to the user code, which gets cache hits.

The same misses would happen in user code if the kernel didn't initialise the page.

$\endgroup$
  • $\begingroup$ So, is the situation like, the kernel has to initialize the pages for the user code and hence the page table entries get entered into the TLB. And since the page entries are already in the TLB, the user code has less compulsory misses for data that it tries to access from those pages. $\endgroup$ – Tapojyoti Mandal Jan 16 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.