# Orchestration Layer

The Orchestration Layer is a responsible for managing the execution workflow of applications deployed on the system. It coordinates task distribution among actors, creates execution contexts, and ensures that applications are efficiently and securely executed. The orchestration process involves several key phases:

### Application Execution Graph Creation

In the first phase of execution, an application is analyzed and transformed into an execution graph. Each application may define multiple entry points (functions) as its potential starting points. During the application launch, the specific entry point is selected and execution begins from that point.

The execution graph represents the logical flow of the application. The nodes of this graph correspond to blocks of instructions (tasks), which are the fundamental units of execution. Each block is designed to be assigned to actors for processing. A block contains one or more instructions, which are categorized into two types:

**Atomic Instructions:** These are indivisible operations within the system’s Instruc- tion Set Architecture (ISA) that can be executed directly by actors without further decomposition.

**Composite Instructions:** These represent high-level operations that may be expanded into a sequence of atomic instructions during the execution planning phase. For instance, a composite instruction like a polynomial evaluation or matrix multiplication might be unrolled into smaller, atomic operations to optimize execution.

The orchestration layer is responsible for constructing the execution graph. It determines dependencies between the blocks and ensures that the graph adheres to the logical flow of the application. The edges in the graph define the dependencies between blocks, ensuring that the execution proceeds in a consistent and orderly manner. This structure allows the orchestration layer to distribute execution efficiently across available actors, optimizing parallelism and resource utilization. Dependencies between blocks are also captured on Orchestration Layer, enabling efficient scheduling and execution.&#x20;

### Process Creation

Once the execution graph is constructed, the system creates a process for the application, similar to traditional Operating systems. A process is an isolated execution entity that encapsulates all orders (blocks of instructions), data and the associated execution context. This approach ensures isolation between different application runs, providing security and stability for the decentralized environment. The process serves as a container for managing the application’s lifecycle, including task execution, resource management, and context handling. It maintains the state of the execution and acts as a boundary for resource allocation and data flow.

### Task Assignment and Actor Selection.&#x20;

The assignment of tasks to specific actors is managed through a decentralized order book. This mechanism allows actors to compete for tasks based on various factors, such as their capabilities, availability, performance history and cost of the computation. The decentralized order book ensures fairness and transparency in task management.

### Execution and Result Aggregation.&#x20;

Once an actor is assigned an order, it retrieves the associated execution context and begins processing the instructions within the block. Key aspects of this phase include:

* Actors execute instructions based on the provided context, handling both atomic and complex operations.
* Dependent orders in the execution graph are activated as their prerequisites are completed, enabling parallelism and efficient resource utilization.
* The Orchestration Layer monitors task progress and ensures that results are correctly propagated through the graph.

```markup
```

