Abstract
The Prolog primitive thread_cancel/1, which simply cancels a thread as recommended in ISO/IEC DTR 13211-5:2007, is conspicuously absent in well-maintained, widely used multithreaded Prolog systems. The ability to cancel a thread is useful for application development and is critical to Prolog embeddability. The difficulty of cancelling a thread is due to the instant mapping of Prolog multithreading primitives to the native-machine thread methods. This paper reports on an attempt to implement thread cancellation using self-blocking threads. A thread blocks at the same safe execution point where the state of the underlying virtual machine is defined. A blocked thread awaits a notification to resume or terminate. A resumed thread may be redirected to self-block by a blocking primitive. Experimental results based on a prototype implementation show that using self-blocking threads not only simplifies the implementation of thread cancellation but also improves the performance of message-passing primitives.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Wielemaker, J., Moura, P., Nunes, P., Robinson, P., Marques, R., Swift, T.: ISO/IEC DTR 13211-5:2007 Prolog Multi-threading Predicates (2007)
Bueno, F., Cabeza, D., Carro, M., Hermenegildo, M., Lopez-Garcıa, P., Puebla, G.: The Ciao Prolog System. Reference Manual (v1. 8). The Ciao System Documentation Series–TR CLIP4/2002.1, School of Computer Science, Technical University of Madrid, UPM (May 2002)
Wielemaker, J.: SWI Prolog 5.6 Reference Manual. Department of Social Science Informatics, University of Amsterdam, Amsterdam, Marz (2006)
Sagonas, K., Swift, T., Warren, D., Freire, J., Rao, P.: XSB Prolog. The XSB System Version 3.1. Programmers Manual, vol. 1 (2007)
Santos-Costa, V., Damas, L., Reis, R., Azevedo, R.: The Yap Prolog Users Manual. Universidade do Porto and COPPE Sistemas (2006)
Moura, P., Crocker, P., Nunes, P.: High-level multi-threading programming in logtalk. In: Hudak, P., Warren, D.S. (eds.) PADL 2008. LNCS, vol. 4902, pp. 265–281. Springer, Heidelberg (2008)
Casas, A., Carro, M., Hermenegildo, M.: Towards a high-level implementation of flexible parallelism primitives for symbolic languages. In: Proceedings of the 2007 International Workshop on Parallel Symbolic Computation, pp. 93–94 (2007)
The IEEE and The Open Group: 1003.1 Standard for Information Technology-Portable Operating System Interface (Posix) System Interfaces, Issue 6. IEEE Std 1003.1-2001. System Interfaces, Issue 6 (2001)
Halen, J., Karlsson, R., Nilsson, M.: Performance measurements of threads in Java and processes in Erlang. Webpage, Last visit (January 2006)
de Bosschere, K., Tarau, P.: Blackboard-based extensions in Prolog. Software—Practice & Experience 26, 49–69 (1996)
Wielemaker, J.: Native preemptive threads in SWI-prolog. In: Palamidessi, C. (ed.) ICLP 2003. LNCS, vol. 2916, pp. 331–345. Springer, Heidelberg (2003)
Eskilson, J., Carlsson, M., Palamidessi, C., Glaser, H., Meinke, K.: SICStus MT—A Multithreaded Execution Environment for SICStus Prolog. In: Palamidessi, C., Meinke, K., Glaser, H. (eds.) ALP 1998 and PLILP 1998. LNCS, vol. 1490, pp. 36–53. Springer, Heidelberg (1998)
Carro, M., Hermenegildo, M.: Concurrency in Prolog Using Threads and a Shared Database. Logic Programming. In: Proceedings of the 1999 International Conference on Logic Programming (1999)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2008 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Suleiman, A., Miller, J. (2008). Implementing Thread Cancellation in Multithreaded Prolog Systems. In: Gill, A., Swift, T. (eds) Practical Aspects of Declarative Languages. PADL 2009. Lecture Notes in Computer Science, vol 5418. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-92995-6_9
Download citation
DOI: https://doi.org/10.1007/978-3-540-92995-6_9
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-92994-9
Online ISBN: 978-3-540-92995-6
eBook Packages: Computer ScienceComputer Science (R0)