---
name: "Csched"
section: "3"
platform: "linux"
package: "liblcgdm-dev"
version: "1.10.0-2+b3"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/Csched"
---

# Csched(3)

LCG Scheduling inferface

## NAME

**Csched** - **LCG** **Scheduling** inferface

## SYNOPSIS

**#include \<Csched\_api.h\>**

**int Csched\_getschedparam(int** *cid***, int \****policy***, Csched\_param\_t \****param***);**

**int Csched\_setschedparam(int** *cid***, int** *policy***, Csched\_param\_t \****param***);**

**int Csched\_get\_priority\_min(int** *policy***);**

**int Csched\_get\_priority\_mid(int** *policy***);**

**int Csched\_get\_priority\_max(int** *policy***);**

## ERRORS

Beyond the errno value, **Csched** is setting the serrno value to generic values that are described in **Cthread**(1).

## DESCRIPTION

**Csched** is a common API interface for scheduling of multithreaded programs.

**Csched\_getschedparam** retrieves the current scheduling policy and priority of the thread referenced with Cthread's id *cid.* The *policy* can be *CSCHED\_OTHER, CSCHED\_FIFO, CSCHED\_RR, CSCHED\_FG\_NP* or *CSCHED\_BG\_NP.* The *param* structure contains a member, named *sched\_priority* , where will be stored the current priority of the thread you ask for. Please read the **NOTES** section.

Return value is 0 on success, or -1 on error.

**Csched\_setschedparam** sets the scheduling policy and priority of the thread referenced with Cthread's id *cid.* The *policy* can be *CSCHED\_OTHER, CSCHED\_FIFO, CSCHED\_RR, CSCHED\_FG\_NP* or *CSCHED\_BG\_NP.* You are neverthless **warned** that the **recommended** scheduling is *CSCHED\_OTHER.* Trying to use another scheduling is an opendoor to processor deadlock if you do not code with extreme care. Furthermore, except *CSCHED\_OTHER* , it is **not** guaranteed that the other possible values ( *CSCHED\_CSCHED\_FIFO, CSCHED\_RR, CSCHED\_FG\_NP* or *CSCHED\_BG\_NP* ) are supported or implemented on your platform. The *param* structure contains a member, named *sched\_priority* , where is given the priority of the thread you want the attributes to be modified. Its value can vary from **Csched\_get\_priority\_min(***policy***)** to **Csched\_get\_priority\_max(***policy***).** Please read the **NOTES** section.

Return value is 0 on success, or -1 on error.

**Csched\_get\_priority\_min**, **Csched\_get\_priority\_mid** and **Csched\_get\_priority\_max are returning the minimum, medium and maximum allowed priorities, respectively, vs. the given** *policy.* **The output is the one that you use in the** *sched\_priority* **member of the Csched\_param\_t structure. Please read the** **NOTES** **section.**

**Return value is != -1 on success, or -1 on error.**

## NOTES

**About scheduling, the Csched interface defines** *CSCHED\_OTHER, CSCHED\_FIFO, CSCHED\_RR, CSCHED\_FG\_NP* **and** *CSCHED\_BG\_NP* **for portability issue. This does** **not** **mean that all those schedulings are supported on the platform you are running on. In particular, only** *CSCHED\_OTHER* **is officially supported everywhere. The other scheduling policies are totally system dependent and do not conform to any standardisation. Please be aware, also, that using a scheduling other than** *CSCHED\_OTHER* **is an opendoor to processor deadlock...**

**Finally, on some OSes, the scheduling interfaces are not necessarly in the thread library, nor in the C library. In particular, on Digital you may find them in librt, and on Solaris in libposix4.**

## SEE ALSO

**Cthread**

## AUTHOR

**LCG Grid Deployment Team**
