Interview Question
as the name suggests "secondary" in itself implies a relatively slower medium which may involve one or more operations to be able to retrieve the data. Consider the case of DRAM being the primary storage and disk being the secondary storage. In that case if the data structure in DRAM has to be written to disk for freeing up space in DRAM would need to be retrieved from the disk and put in memory before the access request can be fulfilled. This is done through the process of page fault handler and is commonly used to scale DRAM by supplementing it through a backing store on disk. Please note from a performance perspective higher the number of page faults, has a direct impact in terms of latency in your application
As the "secondary" in the question suggests and it is assumed that it is slower than primary memory it is shown here with example that large page tables can be written to secondary storage and hence has the potential of being slower.
- RS August 03, 2016Most often primary memory is referred to as DRAM and secondary memory is the disk with a magnitude higher in access times. When an application has demands on more memory in DRAM operating systems will take some of the unused memory (LRU) and write its contents into disks and then provide that space to the calling application. All of this is done in the context of the memory access request. when the original process who owned the memory tries to access it again then the memory subsystem performs a page fault leading to the handler in reading the contents of memory from secondary storage into primary and then completing the request to application. It maybe noted that this process of page fault does add to the additional latency in accessing memory. The aspect of performance penalty will be observed when the number of page faults are frequent enough that the operating system is constantly in the process of reading and writing contents to secondary storage i.e. a imbalance in system resources due to the application demand on the available resources.