# 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](https://devs.truebit.io/architecture/introduction/truebit-verify-nodes#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.
