7 Managing OS-Level Threads (CS)

► |  | Inside: Racket C API

I | Inside Racket CS
II | Inside Racket BC (3m and CGC)
III | Appendices
| Index

▼ | I | Inside Racket CS

1 | Overview (CS)
2 | Embedding into a Program (CS)
3 | Values and Types (CS)
4 | Calling Procedures (CS)
5 | Starting and Declaring Initial Modules (CS)
6 | Evaluation and Running Modules (CS)
7 | Managing OS-Level Threads (CS)

top contents ← prev up next →

### 7`` Managing OS-Level Threads (CS)🔗ℹ

Chez Scheme functionality can only be accessed from OS-level threads that are known to the Chez Scheme runtime system. Otherwise, there’s a race condition between such an access and a garbage collection that is triggered by other threads.

A thread not created by Chez Scheme can be made known to the runtime system by activating it with Sactivate_thread. As long as a thread is active by not running Chez Scheme code, the thread prevents garbage collection in all other running threads. Deactivate a thread using Sdeactivate_thread.

int |  | Sactivate_thread | ( | )

Activates the current OS-level thread. An already-activated thread can be activated again, but each activation must be balanced by a decativation. The result is 0 if the thread was previously activated 1 otherwise.

void |  | Sdeactivate_thread | ( | )

Deactivates the current OS-level thread—or, at least, balances on activation, making the thread deactive if there are no remaining activations to balance with deactivation.

int |  | Sdestroy_thread | ( | )

Releases any Chez Scheme resources associated with the current OS thread, which must have been previously activated but which must not be activated still.
top contents ← prev up next →