# Scheduling (OpenMP) **Scheduling** in OpenMP controls how loop iterations are divided among threads. By default, `parallel for` splits iterations into roughly equal static chunks assigned to threads upfront. This works well when each iteration takes the same time. When iteration cost varies, static assignment leaves some threads idle while others are still running. A loop where some values of `i` trigger much more work than others is a common example. The `schedule` clause selects the assignment strategy. ```c #pragma omp parallel for schedule(dynamic, 4) for (int i = 0; i < N; i++) { process(i); // variable cost per iteration } ``` The main schedule kinds are: - `static` — divide iterations into equal chunks upfront; lowest overhead, best when work is uniform - `dynamic[, chunk]` — threads pull the next chunk from a queue when they finish; good for uneven work - `guided[, chunk]` — like dynamic but chunks start large and shrink as the loop progresses - `runtime` — defer the decision to the `OMP_SCHEDULE` environment variable - `auto` — let the compiler or runtime choose The optional chunk size (e.g. `dynamic, 4`) controls how many iterations a thread grabs at once. Smaller chunks improve load balance but increase scheduler overhead.