Skip to main content

Implementing Thread Cancellation in Multithreaded Prolog Systems

  • Conference paper
Practical Aspects of Declarative Languages (PADL 2009)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 5418))

Included in the following conference series:

  • 412 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Wielemaker, J., Moura, P., Nunes, P., Robinson, P., Marques, R., Swift, T.: ISO/IEC DTR 13211-5:2007 Prolog Multi-threading Predicates (2007)

    Google Scholar 

  2. 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)

    Google Scholar 

  3. Wielemaker, J.: SWI Prolog 5.6 Reference Manual. Department of Social Science Informatics, University of Amsterdam, Amsterdam, Marz (2006)

    Google Scholar 

  4. Sagonas, K., Swift, T., Warren, D., Freire, J., Rao, P.: XSB Prolog. The XSB System Version 3.1. Programmers Manual, vol. 1 (2007)

    Google Scholar 

  5. Santos-Costa, V., Damas, L., Reis, R., Azevedo, R.: The Yap Prolog Users Manual. Universidade do Porto and COPPE Sistemas (2006)

    Google Scholar 

  6. 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)

    Chapter  Google Scholar 

  7. 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)

    Google Scholar 

  8. 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)

    Google Scholar 

  9. Halen, J., Karlsson, R., Nilsson, M.: Performance measurements of threads in Java and processes in Erlang. Webpage, Last visit (January 2006)

    Google Scholar 

  10. de Bosschere, K., Tarau, P.: Blackboard-based extensions in Prolog. Software—Practice & Experience 26, 49–69 (1996)

    Article  Google Scholar 

  11. Wielemaker, J.: Native preemptive threads in SWI-prolog. In: Palamidessi, C. (ed.) ICLP 2003. LNCS, vol. 2916, pp. 331–345. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  12. 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)

    Chapter  Google Scholar 

  13. 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)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics