A Formal C-Based Simulation Framework for Comparative Analysis of Paging and Segmentation Memory Management: Mathematical Modelling, Algorithmic Evaluation, and Fragmentation Quantification
Downloads
Memory management constitutes one of the most consequential responsibilities of a modern operating system kernel. Among the classical memory management paradigms, paging and segmentation represent two fundamentally distinct strategies for mapping logical address spaces onto physical memory. Paging partitions memory into fixed-size units called frames and pages, achieving immunity from external fragmentation at the cost of internal fragmentation. Segmentation, conversely, imposes variable-size logical units aligned with program structure, facilitating natural sharing and protection, yet inherently generating external fragmentation over time. Despite their conceptual simplicity, an empirically grounded, quantitative comparison of these two schemes under a unified, configurable simulation environment remains an underserved contribution in the operating systems literature.
This paper presents a formally designed, byte-level C simulation framework that independently models paging and segmentation within a shared configurable memory space. The simulator implements four canonical placement strategies for segmentation (First-Fit, Best-Fit, Next-Fit, and Worst-Fit), an optional swap-space extension for paging, and a memory compaction operator for segmentation. We derive closed-form mathematical models for internal and external fragmentation, validate them against simulator output, and conduct five controlled experiments: (i) page-size sensitivity analysis, (ii) placement-strategy comparison for segmentation, (iii) workload-scalability analysis, (iv) compaction effectiveness evaluation, and (v) address-translation correctness verification. Simulation results demonstrate that internal fragmentation in paging is bounded by O(n × P) where n is the number of processes and P is the page size, whereas external fragmentation in segmentation grows monotonically with allocation-deallocation cycles regardless of placement strategy, and is reduced to zero by compaction at a cost of O(M) data movement where M is the total memory size. The framework is publicly reproducible and serves dual purposes as a research instrument and a pedagogical tool.
Silberschatz, P. B. Galvin, and G. Gagne, Operating System Concepts, 10th ed. Hoboken, NJ, USA: Wiley, 2018.
S. Tanenbaum and H. Bos, Modern Operating Systems, 4th ed. Upper Saddle River, NJ, USA: Pearson, 2015.
W. Stallings, Operating Systems: Internals and Design Principles, 9th ed. Hoboken, NJ, USA: Pearson, 2018.
S. E. Madnick and J. J. Donovan, Operating Systems. New York, NY, USA: McGraw-Hill, 1974.
L. Liu and J. W. Layland, “Scheduling algorithms for multiprogramming in a hard real-time environment,” J. ACM, vol. 20, no. 1, pp. 46–61, Jan. 1973.
E. Knuth, The Art of Computer Programming, Vol. 1: Fundamental Algorithms, 3rd ed. Reading, MA, USA: Addison-Wesley, 1997.
P. R. Wilson, M. S. Johnstone, M. Neely, and D. Boles, “Dynamic storage allocation: A survey and critical review,” in Proc. Int. Workshop Memory Manage. (IWMM), Kinross, Scotland, 1995, pp. 1–116.
Randell, “A note on storage fragmentation and program segmentation,” Commun. ACM, vol. 12, no. 7, pp. 365–372, Jul. 1969.
M. K. McKusick, G. V. Neville-Neil, and R. N. M. Watson, The Design and Implementation of the FreeBSD Operating System, 2nd ed. Upper Saddle River, NJ, USA: Pearson, 2015.
Kernighan and D. Ritchie, The C Programming Language, 2nd ed. Upper Saddle River, NJ, USA: Prentice Hall, 1988.
