Hostname: page-component-8448b6f56d-c4f8m Total loading time: 0 Render date: 2024-04-16T04:16:32.879Z Has data issue: false hasContentIssue false

Real-time MLton: A Standard ML runtime for real-time functional programs

Published online by Cambridge University Press:  31 August 2021

BHARGAV SHIVKUMAR
Affiliation:
University at Buffalo, Buffalo, NY 14260, USA (e-mails: bhargavs@buffalo.edu, jcmurphy@buffalo.edu, lziarek@buffalo.edu)
JEFFREY MURPHY
Affiliation:
University at Buffalo, Buffalo, NY 14260, USA (e-mails: bhargavs@buffalo.edu, jcmurphy@buffalo.edu, lziarek@buffalo.edu)
LUKASZ ZIAREK
Affiliation:
University at Buffalo, Buffalo, NY 14260, USA (e-mails: bhargavs@buffalo.edu, jcmurphy@buffalo.edu, lziarek@buffalo.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

There is a growing interest in leveraging functional programming languages in real-time and embedded contexts. Functional languages are appealing as many are strictly typed, amenable to formal methods, have limited mutation, and have simple but powerful concurrency control mechanisms. Although there have been many recent proposals for specialized domain-specific languages for embedded and real-time systems, there has been relatively little progress on adapting more general purpose functional languages for programming embedded and real-time systems. In this paper, we present our current work on leveraging Standard ML (SML) in the embedded and real-time domains. Specifically, we detail our experiences in modifying MLton, a whole-program optimizing compiler for SML, for use in such contexts. We focus primarily on the language runtime, reworking the threading subsystem, object model, and garbage collector. We provide preliminary results over a radar-based aircraft collision detector ported to SML.

Type
Research Article
Copyright
© CSIRO and The Author(s), 2021. Published by Cambridge University Press.

References

Anderson, B. (2013) Abandoning segmented stacks in Rust. Available at: https://mail.mozilla.org/pipermail/rust-dev/2013-November/006314.html.Google Scholar
Appel, A. W. & MacQueen, D. B. (1987) A standard ML compiler. In Functional Programming Languages and Computer Architecture, Kahn, G. (ed). FPCA 1987. Lecture Notes in Computer Science, vol. 274. Berlin, Heidelberg: Springer. https://doi.org/10.1007/3-540-18317-5_17.CrossRefGoogle Scholar
Appel, A. W. & Shao, Z. (1996) An empirical and analytic study of stack vs. heap cost for languages with closures. J. Funct. Program. 6, 4774. https://doi.org/10.1017/S095679680000157X.CrossRefGoogle Scholar
Arts, T., Benac Earle, C. & Derrick, J. (2004) Development of a verified Erlang program for resource locking. Int. J. Softw. Tools Technol. Transf. 5(2), 205220.CrossRefGoogle Scholar
Audebaud, P. & Paulin-Mohring, C. (2009) Proofs of randomized algorithms in Coq. Sci. Comput. Program. 74(8), 568589. Special Issue on Mathematics of Program Construction (MPC 2006).CrossRefGoogle Scholar
Bacon, D. F., Cheng, P. & Rajan, V. T. (2003) Controlling fragmentation and space consumption in the Metronome, a real-time garbage collector for Java. In Proceedings of the 2003 ACM SIGPLAN Conf. on Language, Compiler, and Tool for Embedded Systems. LCTES’03. ACM, pp. 8192.CrossRefGoogle Scholar
Baker, T. P. & Shaw, A. (1988) The cyclic executive model and Ada. In Proceedings. Real-Time Systems Symposium, pp. 120129.CrossRefGoogle Scholar
Ballabriga, C., Cassé, H., Rochange, C. & Sainrat, P. (2010) OTAWA: An open toolbox for adaptive WCET analysis. In Software Technologies for Embedded and Ubiquitous Systems, Min, S. L., Pettit, R., Puschner, P. & Ungerer, T. (eds). Berlin, Heidelberg: Springer, pp. 3546.CrossRefGoogle Scholar
Bruggeman, C., Waddell, O. & Dybvig, R. K. (1996) Representing control in the presence of one-shot continuations. SIGPLAN Not. 31(5), 99107.CrossRefGoogle Scholar
Cheney, C. J. (1970) A nonrecursive list compacting algorithm. Commun. ACM 13(11), 677678.CrossRefGoogle Scholar
Cheng, P. (2001) Scalable Real-Time Parallel Garbage Collection for Symmetric Multiprocessors. PhD thesis, USA. AAI3179039.Google Scholar
Clinger, W. D., Hartheimer, A. H. & Ost, E. M. (1999) Implementation strategies for first-class continuations. Higher-Order Symb. Comput. 12(1), 745.CrossRefGoogle Scholar
Deters, M. & Cytron, R. K. (2002) Automated discovery of scoped memory regions for real-time Java. In Proceedings of the 3rd Int’l Symposium on Memory Management. ISMM’02. ACM, pp. 132142.CrossRefGoogle Scholar
Dijkstra, E. W., Lamport, L., Martin, A. J., Scholten, C. S. & Steffens, E. F. M. (1978) On-the-fly garbage collection: An exercise in cooperation. Commun. ACM 21(11), 966975.CrossRefGoogle Scholar
Elsman, M. (1999) Program Modules, Separate Compilation, and Intermodule Optimisation. DIKU.Google Scholar
Elsman, M. & Hallenberg, N. (2020) On the effects of integrating region-based memory management and generational garbage collection in ML. In Practical Aspects of Declarative Languages, Komendantskaya, E. & Liu, Y. A. (eds). Springer International Publishing, pp. 95112.CrossRefGoogle Scholar
Erlang. (2021) Erlang Programming language official website. Available at: http://www.erlang.org/.Google Scholar
Fenichel, R. R. & Yochelson, J. C. (1969) A lisp garbage-collector for virtual-memory computer systems. Commun. ACM 12(11), 611612.CrossRefGoogle Scholar
Gay, D. & Aiken, A. (2001) Language support for regions. SIGPLAN Not. 36(5), 7080.CrossRefGoogle Scholar
Goldstein, S. C. (1997) Lazy Threads Compiler and Runtime Structures for Fine-Grained Parallel Programming. PhD thesis, University of California–Berkeley, Berkeley, CA.Google Scholar
Gosling, J. & Bollella, G. (2000) The Real-Time Specification for Java. Addison-Wesley Longman Publishing Co., Inc.CrossRefGoogle Scholar
Hallenberg, N., Elsman, M. & Tofte, M. (2002a) Combining region inference and garbage collection. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’02). Berlin, Germany: ACM Press.CrossRefGoogle Scholar
Hallenberg, N., Elsman, M. & Tofte, M. (2002b) Combining region inference and garbage collection. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation. PLDI’02. ACM, pp. 141152.CrossRefGoogle Scholar
Hammond, K. (2001) The dynamic properties of hume: A functionally-based concurrent language with bounded time and space behaviour. In Implementation of Functional Languages: 12th Int’l Workshop, IFL 2000 Aachen, Germany, 4–7 September 2000 Selected Papers. Berlin, Heidelberg: Springer, pp. 122139.CrossRefGoogle Scholar
Hammond, K. (2003) Is it time for real-time functional programming? In Revised Selected Papers from the Fourth Symposium on Trends in Functional Programming, TFP 2003, Edinburgh, UK, 11–12 September 2003, Gilmore, S. (ed), vol. 4. Intellect, pp. 118.Google Scholar
Hammond, K., Michaelson, G. & Pointon, R. (2007) The Hume Report, Version 1.1. Available at: http://www-fp.cs.st-andrews.ac.uk/hume/report/hume-report.pdf.Google Scholar
Hamza, H. & Counsell, S. (2012) Region-based RTSJ memory management: State of the art. Sci. Comput. Program. 77(5), 644659.CrossRefGoogle Scholar
Hanson, D. R. (1990) Fast allocation and deallocation of memory based on object lifetimes. Software Pract. Exp. 20(1), 512.CrossRefGoogle Scholar
Hawkins, T. (2010) Atom: A Synchronous Hard Real-Time EDSL for GHC. Available at: https://github.com/tomahawkins/atom.Google Scholar
Henties, T., Hunt, J. J., Locke, D., Nilsen, K., Schoeberl, M. & Vitek, J. (2009) Java for safety-critical applications. In 2nd International Workshop on the Certification of Safety-Critical Software Controlled Systems (SafeCert 2009).Google Scholar
Hieb, R., Dybvig, R. K. & Bruggeman, C. (1990) Representing control in the presence of first-class continuations. In Proceedings of the ACM SIGPLAN 1990 Conference on Programming Language Design and Implementation. PLDI’90. Association for Computing Machinery, pp. 6677.CrossRefGoogle Scholar
Hughes, J. (1989) Why functional programming matters. Comput. J. 32(2), 98107.CrossRefGoogle Scholar
Jones, R., Hosking, A. & Moss, E. (2016) The Garbage Collection Handbook: The Art of Automatic Memory Management. CRC Press.CrossRefGoogle Scholar
Kalibera, T., Hagelberg, J., Pizlo, F., Plsek, A., Titzer, B. & Vitek, J. (2009b) CDx: A family of real-time java benchmarks. In Proceedings of the 7th International Workshop on Java Technologies for Real-Time and Embedded Systems. JTRES’09. ACM, pp. 4150.CrossRefGoogle Scholar
Kalibera, T., Pizlo, F., Hosking, A. & Vitek, J. (2009a) Scheduling hard real-time garbage collection. In 30th IEEE Real-Time Systems Symposium, 2009, RTSS 2009, pp. 8192.CrossRefGoogle Scholar
Kumar, R., Myreen, M. O., Norrish, M. & Owens, S. (2014) CakeML: A verified implementation of ML. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. POPL’14. ACM, pp. 179191.CrossRefGoogle Scholar
Li, M., McArdle, D. E., Murphy, J. C., Shivkumar, B. & Ziarek, L. (2016) Adding real-time capabilities to a SML compiler. SIGBED Rev. 13(2), 813.CrossRefGoogle Scholar
Lipari, G. & Bini, E. (2005) A methodology for designing hierarchical scheduling systems. J. Embedded Comput. 1(2), 257269.Google Scholar
Lisper, B. (2014) SWEET – A tool for WCET flow analysis (extended abstract). In Leveraging Applications of Formal Methods, Verification and Validation. Specialized Techniques and Applications, Margaria, T. & Steffen, B. (eds). Berlin, Heidelberg: Springer, pp. 482485.CrossRefGoogle Scholar
López, N., Núñez, M. & Rubio, F. (2002) Stochastic process algebras meet Eden. In Proceedings of the Third International Conference on Integrated Formal Methods. IFM’02. Springer-Verlag, pp. 2948.CrossRefGoogle Scholar
Marlow, S., Harris, T., James, R. P. & Peyton Jones, S. (2008) Parallel generational-copying garbage collection with a block-structured heap. In ISMM’08: Proceedings of the 7th International Symposium on Memory Management. ACM.CrossRefGoogle Scholar
Milner, R., Tofte, M. & Macqueen, D. (1997) The Definition of Standard ML. MIT Press.CrossRefGoogle Scholar
MLton. (2012) The MLton compiler and runtime system. Available at: http://www.mlton.org.Google Scholar
MLton Performance. (2012) MLton performance benchmarks. Available at: http://mlton.org/Performance.Google Scholar
Morsing, D. (2014) How Stacks are Handled in Go. Available at: https://blog.cloudflare.com/how-stacks-are-handled-in-go/.Google Scholar
Muller, S. K., Acar, U. A. & Harper, R. (2018) Competitive parallelism: Getting your priorities right. Proc. ACM Program. Lang. 2(ICFP).CrossRefGoogle Scholar
Murphy, J. C., Shivkumar, B., Pritchard, A., Iraci, G., Kumar, D., Kim, S. H. & Ziarek, L. (2019) A survey of real-time capabilities in functional languages and compilers. Concurr. Comput. Pract. Exp. 31(4), e4902.CrossRefGoogle Scholar
Nettles, S. & O’Toole, J. (1993) Real-time replication garbage collection. SIGPLAN Not. 28(6), 217226.CrossRefGoogle Scholar
Nicosia, V. (2007) Towards hard real-time Erlang. In Proceedings of the 2007 SIGPLAN Workshop on ERLANG Workshop. ERLANG’07. ACM, pp. 2936.CrossRefGoogle Scholar
Pizlo, F., Ziarek, L., Blanton, E., Maj, P. & Vitek, J. (2010a) High-level programming of embedded hard real-time devices. In Proceedings of the 5th European Conference on Computer systems. EuroSys’10. ACM, pp. 6982.CrossRefGoogle Scholar
Pizlo, F., Ziarek, L., Maj, P., Hosking, A. L., Blanton, E. & Vitek, J. (2010b) Schism: Fragmentation-tolerant real-time garbage collection. In Proceedings of the 2010 ACM SIGPLAN Conference on Programming Language Design and Implementation. PLDI’10. ACM, pp. 146159.CrossRefGoogle Scholar
RapiTime. (2021) Rapita Systems Ltd homepage. Available at: https://www.rapitasystems.com/.Google Scholar
Regehr, J., Reid, A. & Webb, K. (2005) Eliminating stack overflow by abstract interpretation. ACM Trans. Embed. Comput. Syst. 4(4), 751778.CrossRefGoogle Scholar
Reppy, J. H. (1999) Concurrent Programming in ML. Cambridge University Press.CrossRefGoogle Scholar
Reynolds, J. C. (1972) Definitional interpreters for higher-order programming languages. In Proceedings of the ACM Annual Conference, vol. 2. ACM’72. ACM, pp. 717740.CrossRefGoogle Scholar
Ross, D. T. (1967) The AED free storage package. Commun. ACM 10(8), 481492.CrossRefGoogle Scholar
Shivers, O. (1988) Control flow analysis in scheme. In Proceedings of the ACM SIGPLAN 1988 Conference on Programming Language Design and Implementation. PLDI’88. ACM, pp. 164174.CrossRefGoogle Scholar
Shivkumar, B., Murphy, J. C. & Ziarek, L. (2020) RTMLton: An SML runtime for real-time systems. In Practical Aspects of Declarative Languages - 22nd International Symposium, PADL 2020, New Orleans, LA, USA, 20–21 January, 2020, Proceedings, Komendantskaya, E. and Liu, Y. A. (eds). Lecture Notes in Computer Science, vol. 12007. Springer, pp. 113130.CrossRefGoogle Scholar
Siebert, F. (2007) Realtime garbage collection in the JamaicaVM 3.0. In Proceedings of the 5th Int’l Workshop on Java Technologies for Real-time and Embedded Systems. JTRES’07. ACM, pp. 94103.CrossRefGoogle Scholar
Sivaramakrishnan, K. C., Ziarek, L. & Jagannathan, S. (2014) MultiMLton: A multicore-aware runtime for standard ML. J. Funct. Program. 24, 613674.CrossRefGoogle Scholar
Sivaramakrishnan, K., Ziarek, L. & Jagannathan, S. (2012) Eliminating read barriers through procrastination and cleanliness. In Proceedings of the 2012 Int’l Symposium on Memory Management. ISMM’12. ACM, pp. 4960.CrossRefGoogle Scholar
Steele, G. L. (1978) Rabbit: A Compiler for Scheme. Tech. rept. USA.Google Scholar
Timber, Language. (2008) Timber: A Gentle Introduction. Available at: http://www.timber-lang.org/index_gentle.html.Google Scholar
Tofte, M. & Talpin, J.-P. (1997) Region-based memory management. Inf. Comput. 132(2), 109176.CrossRefGoogle Scholar
Tolmach, A. & Oliva, D. P. (1993) From ML to Ada: Strongly-typed language interoperability via source translation. J. Funct. Program. 8, 367412.CrossRefGoogle Scholar
Wan, Z., Taha, W. & Hudak, P. (2001) Real-time FRP. In Proceedings of the Sixth ACM SIGPLAN Int’l Conference on Functional Programming. ICFP’01. ACM, pp. 146156.CrossRefGoogle Scholar
Ziarek, L., Sivaramakrishnan, K. & Jagannathan, S. (2011) Composable asynchronous events. In Proceedings of the 32Nd ACM SIGPLAN Conference on Programming Language Design and Implementation. PLDI’11. ACM, pp. 628639.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.