# Task Instrumentation

### How Does The Instrumentation Process Work?

The instrumentation process injects WebAssembly code through the program to watch for resource usage. When the program exceeds a set amount of resources, it signals that error to the [wasm-runner](/architecture/introduction/truebit-verify-nodes.md#wasm-runner) and immediately aborts execution.

### Link Process&#x20;

The first step in the process is called '**Link**' and it handles the following tasks to guarantee deterministic execution.

### Replace WASI Interface

Replace the default WASI interface with the Truebit WASI implementation&#x20;

### Replace Bulk Memory Instruction

Replace WASM bulk memory extension instructions with basic ones.

### Replace FPU Instructions

Replace the hardware floating point number implementation with a deterministic one created by Truebit.

### Limit Process

The second step in the process is called '**Limit**' and it handles the following tasks to detect resource usage and abort execution wherever it exceeds a set amount.

#### Gas Limit

It limits program execution to a given number of WebAssembly instructions. It allows paying nodes for the execution of up to a maximum number of instructions (the gas). The program won't execute past a given instruction count, even when executing an infinite loop.

#### Stack Limit

It limits stack usage by restricting how much stack memory, in bytes, functions can be used at any given time, including their nested calls.

#### Call Limit

Sets a maximum amount of nested calls, which limits infinite recursion.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/key-concepts/task-instrumentation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
