====== OSA : OS_Task_Create ======
**OS_Task_Create (priority, TaskName)**\\
=== ===
{{osa:ref:attr_call_not_int.png|Not allowed in interrupt}}
Create task. After creation, the task will be added to the list of active tasks.
**For CCS users**: Compiler should be informed that //TaskName// will be called indirectly by using the service ##[[en:osa:ref:allservices:OS_Task_Define|OS_Task_Define]]## in main().
**For mikroC users**: All function-tasks should be defined with the #pragma fncall directive, e.g.:\\ \\
###pragma fncall main MyTask##\\
##void MyTask (void)##\\
##{##\\
\ \ \ \ ...
=== Call allowed: ===
Not in interrupt
=== Parameters: ===
{| class = "fpl"
|-
|//''priority''//
|Task priority. Allowed values from 0 (highest) to 7 (lowest).
|-
|//''TaskName''//
|Name of C-function to be used as task
|}
=== Returns: ===
{| class = "fpl"
|-
|//''bError''//
|If there is no free descriptor to create task then ##[[en:osa:ref:allservices:OS_IsEventError|OS_IsError]]## will return **true**
|}
=== Example: ===
void Task1 (void)
{
for (;;) OS_Yield();
}
void Task2 (void)
{
for (;;) OS_Yield();
}
void main (void)
{
OS_Init();
OS_Task_Create(1, Task1); // Create task Task1 with priority 1
OS_Task_Create(5, Task2); // Create task Task2 with priority 5
/*...*/
}
=== Old style name ===
**OS_CreateTask**\\
=== See also ===
* [[en:osa:ref:allservices:OS_Task_Create|OS_Task_Create]]
* [[en:osa:ref:allservices:OS_Task_Replace|OS_Task_Replace]]
* [[en:osa:ref:allservices:OS_Task_Delete|OS_Task_Delete]]
* [[en:osa:ref:allservices:OS_Task_Define|OS_Task_Define]]
* [[en:osa:ref:allservices:OS_Task_GetCur|OS_Task_GetCur]]
* [[en:osa:ref:allservices:OS_Task_GetCreated|OS_Task_GetCreated]]
* [[en:osa:ref:allservices:OS_Task_Pause|OS_Task_Pause]]
* [[en:osa:ref:allservices:OS_Task_Continue|OS_Task_Continue]]
* [[en:osa:ref:allservices:OS_Task_IsPaused|OS_Task_IsPaused]]
* [[en:osa:ref:allservices:OS_Task_GetPriority|OS_Task_GetPriority]]
* [[en:osa:ref:allservices:OS_Task_SetPriority|OS_Task_SetPriority]]
----
* [[en:osa:ref:services:alphabetical|Alphabetical]]
* [[en:osa:ref:services:brieflist|All services]]
~~UP~~