1#lang scribble/doc 2@(require "utils.rkt") 3 4@cs-title[#:tag "cs-thread"]{Managing OS-Level Threads} 5 6Chez Scheme functionality can only be accessed from OS-level threads 7that are known to the Chez Scheme runtime system. Otherwise, there's a 8race condition between such an access and a garbage collection that is 9triggered by other threads. 10 11A thread not created by Chez Scheme can be made known to the runtime 12system by activating it with @cppi{Sactivate_thread}. As long as a 13thread is active by not running Chez Scheme code, the thread prevents 14garbage collection in all other running threads. Deactivate a thread 15using @cppi{Sdeactivate_thread}. 16 17@function[(int Sactivate_thread)]{ 18 19Activates the current OS-level thread. An already-activated thread can 20be activated again, but each activation must be balanced by a 21decativation. The result is @cpp{0} if the thread was previously 22activated @cpp{1} otherwise.} 23 24@function[(void Sdeactivate_thread)]{ 25 26Deactivates the current OS-level thread---or, at least, balances on 27activation, making the thread deactive if there are no remaining 28activations to balance with deactivation.} 29 30@function[(int Sdestroy_thread)]{ 31 32Releases any Chez Scheme resources associated with the current OS 33thread, which must have been previously activated but which must not 34be activated still.} 35