A Verified Specification of TLSF Memory Management Allocator Using State Monads

  • Yu Zhang
  • Yongwang ZhaoEmail author
  • David Sanan
  • Lei Qiao
  • Jinkun Zhang
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11951)


Formal verification of real-time services is important because they are usually associated with safety-critical systems. In this paper, we present a verified Two-Level Segregated Fit (TLSF) memory management model. TLSF is a dynamic memory allocator and is designed for real-time operating systems. We formalize the specification of TLSF algorithm based on the client requirements. The specification contains both functional correctness of allocation and free services and invariants and constraints of the global memory state. Then we implement an abstract TLSF memory allocator using state monads in Isabelle/HOL. The allocator model is built from a high-level view and the details of data structures are simplified but it covers all the behavioral principles and procedures of a concrete TLSF implementation. Finally, we verify that our TLSF model is correct w.r.t. the specification using a verification condition generator (VCG) and verification tools in Isabelle/HOL.


Formal verification Memory management Isabelle/HOL 


  1. 1.
    TLSF: Memory allocator real time embedded systems.
  2. 2.
    Masmano, M., Ripoll, I., Crespo, A., Real, J.: TLSF: a new dynamic memory allocator for real-time systems. In: Proceedings of the 16th Euromicro Conference on Real-Time Systems, ECRTS 2004, Catania, Italy, 2004, pp. 79–88.
  3. 3.
    Masmano, M., Ripoll, I., Real, J., Crespo, A., Wellings, A.J.: Implementation of a constant time dynamic storage allocator. Softw. Pract. Exp. 38, 995–1026 (2008). Scholar
  4. 4.
    Cock, D., Klein, G., Sewell, T.: Secure microkernels, state monads and scalable refinement. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 167–182. Springer, Heidelberg (2008). Scholar
  5. 5.
    Nipkow, T., Wenzel, M., Paulson, L.C.: Isabelle/HOL: A Proof Assistant for Higher-Order Logic. Springer, Heidelberg (2002). CrossRefzbMATHGoogle Scholar
  6. 6.
    Saraswat, V.A., Jagadeesan, R., Michael, M., von Praun, C.: A theory of memory models. In: Proceedings of the 12th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP), pp. 161–172. ACM (2007)Google Scholar
  7. 7.
    Yu, D., Hamid, N.A., Shao, Z.: Building Certified libraries for PCC: dynamic storage allocation. In: Degano, P. (ed.) ESOP 2003. LNCS, vol. 2618, pp. 363–379. Springer, Heidelberg (2003). Scholar
  8. 8.
    Leroy, X., Blazy, S.: Formal verification of a C-like memory model and its uses for verifying program transformations. J. Autom. Reason. 41(1), 1–31 (2008)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Tews, H., Völp, M., Weber, T.: Formal memory models for the verification of low-level operating-system code. J. Autom. Reason. 42(2), 189–227 (2009)CrossRefGoogle Scholar
  10. 10.
    Gallardo, M.d.M., Merino, P., Sanán, D.: Model checking dynamic memory allocation in operating systems. J. Autom. Reason. 42(2), 229–264 (2009)MathSciNetCrossRefGoogle Scholar
  11. 11.
    Ševčík, J., Vafeiadis, V., Zappa Nardelli, F., Jagannathan, S., Sewell, P.: CompCertTSO: a verified compiler for relaxed-memory concurrency. J. ACM (JACM) 60(3), 22:1–22:50 (2013)CrossRefGoogle Scholar
  12. 12.
    Mansky, W., Garbuzov, D., Zdancewic, S.: An axiomatic specification for sequential memory models. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9207, pp. 413–428. Springer, Cham (2015). Scholar
  13. 13.
    Vaynberg, A., Shao, Z.: Compositional verification of a baby virtual memory manager. In: Hawblitzel, C., Miller, D. (eds.) CPP 2012. LNCS, vol. 7679, pp. 143–159. Springer, Heidelberg (2012). Scholar
  14. 14.
    Gu, R., et al.: CertiKOS: an extensible architecture for building certified concurrent OS kernels. In: 12th USENIX Symposium on Operating Systems Design and Implementation (OSDI), Savannah, GA, pp. 653–669. USENIX Association (2016)Google Scholar
  15. 15.
    Klein, G., et al.: seL4: formal verification of an OS kernel. In: 22nd ACM SIGOPS Symposium on Operating Systems Principles (SOSP), pp. 207–220. ACM Press (2009)Google Scholar
  16. 16.
    Klein, G., Tuch, H.: Towards verified virtual memory in L4. In: TPHOLs Emerging Trends, Park City, Utah, USA, 16 pages, September 2004Google Scholar
  17. 17.
    Alkassar, E., Schirmer, N., Starostin, A.: Formal pervasive verification of a paging mechanism. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 109–123. Springer, Heidelberg (2008). Scholar
  18. 18.
    Blanchard, A., Kosmatov, N., Lemerre, M., Loulergue, F.: A case study on formal verification of the anaxagoros hypervisor paging system with frama-C. In: Núñez, M., Güdemann, M. (eds.) FMICS 2015. LNCS, vol. 9128, pp. 15–30. Springer, Cham (2015). Scholar
  19. 19.
    Bolignano, P., Jensen, T., Siles, V.: Modeling and abstraction of memory management in a hypervisor. In: Stevens, P., Wąsowski, A. (eds.) FASE 2016. LNCS, vol. 9633, pp. 214–230. Springer, Heidelberg (2016). Scholar
  20. 20.
    Su, W., Abrial, J., Pu, G., Fang, B.: Formal development of a real-time operating system memory manager. In: 2015 20th International Conference on Engineering of Complex Computer Systems (ICECCS), Gold Coast, QLD, pp. 130–139 (2015).
  21. 21.
    Fang, B., Sighireanu, M.: Hierarchical shape abstraction for analysis of free list memory allocators. In: Hermenegildo, M.V., Lopez-Garcia, P. (eds.) LOPSTR 2016. LNCS, vol. 10184, pp. 151–167. Springer, Cham (2017). Scholar
  22. 22.
    Fang, B., Sighireanu, M.: A refinement hierarchy for free list memory allocators. In: Proceedings of the 2017 ACM SIGPLAN International Symposium on Memory Management, pp. 104–114. ACM (2017)Google Scholar
  23. 23.
    Fang, B., Sighireanu, M., Pu, G., Su, W., Abrial, J.R., Yang, M., Qiao, L.: Formal modelling of list based dynamic memory allocators. Sci. China Inf. Sci. 61(12), 103–122 (2018)CrossRefGoogle Scholar
  24. 24.
    Marti, N., Affeldt, R., Yonezawa, A.: Formal verification of the heap manager of an operating system using separation logic. In: Liu, Z., He, J. (eds.) ICFEM 2006. LNCS, vol. 4260, pp. 400–419. Springer, Heidelberg (2006). Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  • Yu Zhang
    • 1
  • Yongwang Zhao
    • 1
    Email author
  • David Sanan
    • 2
  • Lei Qiao
    • 3
  • Jinkun Zhang
    • 3
  1. 1.School of Computer Science and EngineeringBeihang UniversityBeijingChina
  2. 2.School of Computer Science and EngineeringNanyang Technology UniversitySingaporeSingapore
  3. 3.Beijing Institute of Control EngineeringBeijingChina

Personalised recommendations