TizenRT Public API  v2.0 M2
Task_Manager

Provides APIs for Task Manager. More...

Files

file  task_manager.h
 
file  task_manager_broadcast_list.h
 User specific broadcast messages are declared at this file.
 

Data Structures

struct  tm_appinfo_s
 Application Info Structure. More...
 
struct  tm_appinfo_list_s
 
struct  tm_msg_s
 Unicast message Structure. More...
 

Macros

#define TM_APP_STATE_RUNNING   (1)
 Task State which managed by Task Manager. More...
 
#define TM_APP_PERMISSION_ALL   (0)
 Task Permission. More...
 
#define TM_NO_RESPONSE   (0)
 Returnable Flag from Task Manager. More...
 

Typedefs

typedef void(* _tm_unicast_t) (tm_msg_t *)
 Unicast callback function type. More...
 
typedef void(* _tm_broadcast_t) (void *, void *)
 Broadcast callback function type. More...
 
typedef void(* _tm_termination_t) (void *)
 Termination callback function type. More...
 

Enumerations

Functions

int task_manager_register_builtin (char *name, int permission, int timeout)
 Request to register a built-in task. More...
 
int task_manager_register_task (char *name, int priority, int stack_size, main_t entry, char *argv[], int permission, int timeout)
 Request to register a task which is not in built-in list. More...
 
int task_manager_register_pthread (char *name, pthread_attr_t *attr, pthread_startroutine_t start_routine, pthread_addr_t arg, int permission, int timeout)
 Request to register a pthread which is not in built-in list. More...
 
int task_manager_unregister (int handle, int timeout)
 Request to unregister a task. More...
 
int task_manager_start (int handle, int timeout)
 Request to start the task. More...
 
int task_manager_stop (int handle, int timeout)
 Request to stop the task. More...
 
int task_manager_pause (int handle, int timeout)
 Request to pause the task. More...
 
int task_manager_resume (int handle, int timeout)
 Request to resume the task. More...
 
int task_manager_restart (int handle, int timeout)
 Request to restart the task. More...
 
int task_manager_unicast (int handle, tm_msg_t *send_msg, tm_msg_t *reply_msg, int timeout)
 Request to send messages to the task. More...
 
int task_manager_broadcast (int msg, tm_msg_t *data, int timeout)
 Request to send messages to the tasks. More...
 
int task_manager_set_unicast_cb (void(*func)(tm_msg_t *data))
 Set unicast callback function API. More...
 
int task_manager_set_broadcast_cb (int msg, void(*func)(void *user_data, void *data), tm_msg_t *cb_data)
 Register callback function which will be used for processing a certain received broadcast message. More...
 
int task_manager_set_exit_cb (void(*func)(void *data), tm_msg_t *cb_data)
 Set callback function called when task terminates normally. More...
 
int task_manager_set_stop_cb (void(*func)(void *data), tm_msg_t *cb_data)
 Set callback function called when task is stopped by task manager. More...
 
tm_appinfo_list_ttask_manager_getinfo_with_name (char *name, int timeout)
 Get task information list through task name. More...
 
tm_appinfo_ttask_manager_getinfo_with_handle (int handle, int timeout)
 Get task information through handle. More...
 
tm_appinfo_list_ttask_manager_getinfo_with_group (int group, int timeout)
 Get task information list through group. More...
 
tm_appinfo_ttask_manager_getinfo_with_pid (int pid, int timeout)
 Get the handle through pid. More...
 
void task_manager_clean_info (tm_appinfo_t **info)
 Clean task information. More...
 
void task_manager_clean_infolist (tm_appinfo_list_t **info_list)
 Clean task information list. More...
 
int task_manager_reply_unicast (tm_msg_t *reply_msg)
 Send unicast reply message. More...
 
int task_manager_alloc_broadcast_msg (void)
 Allocate a new broadcast message which is not defined in the <task_manager/task_manager.h>
and <task_manager/task_manager_broadcast_list.h> More...
 
int task_manager_unset_broadcast_cb (int msg, int timeout)
 Unregister callback function which was used for a certain broadcast message. More...
 
int task_manager_dealloc_broadcast_msg (int msg, int timeout)
 Remove the broadcast message which was allocated by using task_manager_alloc_broadcast_msg() API. More...
 

Detailed Description

Provides APIs for Task Manager.

Macro Definition Documentation

#define TM_APP_PERMISSION_ALL   (0)

Task Permission.

TM_APP_PERMISSION_ALL : Any Task can request the control to Task Manager TM_APP_PERMISSION_GROUP : Only same group task can request the control to Task Manager -> group : Tasks set which registered from same parent task TM_APP_PERMISSION_DEDICATE : Only a task which requested to register that task can request the control to Task Manager

Definition at line 54 of file task_manager.h.

#define TM_APP_STATE_RUNNING   (1)

Task State which managed by Task Manager.

Definition at line 40 of file task_manager.h.

#define TM_NO_RESPONSE   (0)

Returnable Flag from Task Manager.

These defined can be used in timeout argument for most of the task manager APIs.
If timeout argument is greater than 0, its API will wait to receive during timeout milliseconds.

Definition at line 63 of file task_manager.h.

Typedef Documentation

typedef void(* _tm_broadcast_t) (void *, void *)

Broadcast callback function type.

Definition at line 140 of file task_manager.h.

typedef void(* _tm_termination_t) (void *)

Termination callback function type.

Definition at line 145 of file task_manager.h.

typedef void(* _tm_unicast_t) (tm_msg_t *)

Unicast callback function type.

Definition at line 135 of file task_manager.h.

Enumeration Type Documentation

Broadcast message list.

These values can be used for broadcast messages.
If user wants to add some other types of broadcast message,
user can add their own broadcast messages at <task_manager/task_manager_broadcast_list.h>.

Definition at line 97 of file task_manager.h.

Error Type of Result Value returned from Task Manager.

If operation is failed, these defined values will be returned.

Definition at line 70 of file task_manager.h.

Function Documentation

int task_manager_alloc_broadcast_msg ( void  )

Allocate a new broadcast message which is not defined in the <task_manager/task_manager.h>
and <task_manager/task_manager_broadcast_list.h>

#include <task_manager/task_manager.h>

Returns
On success, a newly allocated broadcast message value is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_broadcast ( int  msg,
tm_msg_t data,
int  timeout 
)

Request to send messages to the tasks.

#include <task_manager/task_manager.h>

Parameters
[in]msgmessage structure to be unicasted
[in]datadata and its size to be broadcasted
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
(This return value only checks whether a broadcast message has been requested
to the task manager to broadcast.)
Since
TizenRT v2.0
void task_manager_clean_info ( tm_appinfo_t **  info)

Clean task information.

#include <task_manager/task_manager.h>

Parameters
[in]infothe task information
Returns
none
Since
TizenRT v2.0
void task_manager_clean_infolist ( tm_appinfo_list_t **  info_list)

Clean task information list.

#include <task_manager/task_manager.h>

Parameters
[in]info_listthe task information list
Returns
none
Since
TizenRT v2.0
int task_manager_dealloc_broadcast_msg ( int  msg,
int  timeout 
)

Remove the broadcast message which was allocated by using task_manager_alloc_broadcast_msg() API.

#include <task_manager/task_manager.h>

Parameters
[in]msgthe message which to be removed.
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
tm_appinfo_list_t* task_manager_getinfo_with_group ( int  group,
int  timeout 
)

Get task information list through group.

#include <task_manager/task_manager.h> After using the list of task information, use task_manager_clean_infolist() API to free the allocated memory.

Parameters
[in]groupthe group id to get information
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, the task information is returned. On failure, NULL is returned.
Since
TizenRT v2.0
tm_appinfo_t* task_manager_getinfo_with_handle ( int  handle,
int  timeout 
)

Get task information through handle.

#include <task_manager/task_manager.h> After using the task information, use task_manager_clean_info() API to free the allocated memory.

Parameters
[in]handlethe handle id to get information
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, the task information is returned. On failure, NULL is returned.
Since
TizenRT v2.0
tm_appinfo_list_t* task_manager_getinfo_with_name ( char *  name,
int  timeout 
)

Get task information list through task name.

#include <task_manager/task_manager.h> After using the list of task information, use task_manager_clean_infolist() API to free the allocated memory.

Parameters
[in]namethe task name to get information
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, the list of task information is returned(at the end of the list, NULL will be returned). On failure, NULL is returned.
Since
TizenRT v2.0
tm_appinfo_t* task_manager_getinfo_with_pid ( int  pid,
int  timeout 
)

Get the handle through pid.

#include <task_manager/task_manager.h>

Parameters
[in]pidthe pid which to get its task information
[in]timeoutreturnable flag. It can be one of the below.
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
For this API, timeout cannot be set to TM_NO_RESPONSE.
Returns
On success, the task information is returned. On failure, NULL is returned.
Since
TizenRT v2.0
int task_manager_pause ( int  handle,
int  timeout 
)

Request to pause the task.

#include <task_manager/task_manager.h>

Parameters
[in]handlethe handle id of task to be paused
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_register_builtin ( char *  name,
int  permission,
int  timeout 
)

Request to register a built-in task.

#include <task_manager/task_manager.h>
This API can request to register a built-in task.
Find apps/builtin/README.md to know how to use built-in task.

Parameters
[in]namethe name of task to be registered
[in]permissionthe permission of task to be registered
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, handle id is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_register_pthread ( char *  name,
pthread_attr_t *  attr,
pthread_startroutine_t  start_routine,
pthread_addr_t  arg,
int  permission,
int  timeout 
)

Request to register a pthread which is not in built-in list.

#include <task_manager/task_manager.h>

Parameters
[in]namethe name of pthread to be registered
[in]attrthe attribute of pthread to be registered
[in]start_routinethe entry function pointer
[in]argthe argument to pass when task creation
[in]permissionthe permission of task to be registered
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, handle id is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_register_task ( char *  name,
int  priority,
int  stack_size,
main_t  entry,
char *  argv[],
int  permission,
int  timeout 
)

Request to register a task which is not in built-in list.

#include <task_manager/task_manager.h>
Find apps/builtin/README.md to know how to use built-in task.

Parameters
[in]namethe name of task to be registered
[in]prioritythe priority of task to be registered
[in]stack_sizethe stack_size of task to be registered
[in]entrythe entry function pointer
[in]argvthe argument to pass when task creation
[in]permissionthe permission of task to be registered
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, handle id is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_reply_unicast ( tm_msg_t reply_msg)

Send unicast reply message.

#include <task_manager/task_manager.h>

Parameters
[in]reply_msgthe pointer of msg for reply
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_restart ( int  handle,
int  timeout 
)

Request to restart the task.

#include <task_manager/task_manager.h> It cannot guarantee the resource de-allocation.

Parameters
[in]handlethe handle id of task to be restarted
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_resume ( int  handle,
int  timeout 
)

Request to resume the task.

#include <task_manager/task_manager.h>

Parameters
[in]handlethe handle id of task to be resumed
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_set_broadcast_cb ( int  msg,
void(*)(void *user_data, void *data)  func,
tm_msg_t cb_data 
)

Register callback function which will be used for processing a certain received broadcast message.

#include <task_manager/task_manager.h>

Parameters
[in]msga certain broadcast message.
When this message is received, the callback function func is called.
Pre defined broadcast messages are presented at the top of <task_manager/task_manager.h>.
User can add pre defined broadcast messages at the <task_manager/task_manager_broadcast_list.h>
If this message is not pre defined at the <task_manager/task_manager.h> and <task_manager/task_manager_broadcast_list.h>,
user should use task_manager_alloc_broadcast_msg() API to get a new broadacast message.
[in]functhe callback function which will be called when a msg is received.
[in]cb_dataa message structure to pass to the callback function func.
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_set_exit_cb ( void(*)(void *data)  func,
tm_msg_t cb_data 
)

Set callback function called when task terminates normally.

#include <task_manager/task_manager.h>

Parameters
[in]functhe callback function that is called when the task or thread terminates normally.
[in]cb_dataa data pointer to pass to the callback function func.
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_set_stop_cb ( void(*)(void *data)  func,
tm_msg_t cb_data 
)

Set callback function called when task is stopped by task manager.

#include <task_manager/task_manager.h>

Parameters
[in]functhe callback function that is called when the task or thread is stopped by task manager.
[in]cb_dataa data pointer to pass to the callback function func.
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_set_unicast_cb ( void(*)(tm_msg_t *data)  func)

Set unicast callback function API.

#include <task_manager/task_manager.h>

Parameters
[in]functhe callback function which handle the msg
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_start ( int  handle,
int  timeout 
)

Request to start the task.

#include <task_manager/task_manager.h>

Parameters
[in]handlethe handle id of task to be started
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_stop ( int  handle,
int  timeout 
)

Request to stop the task.

#include <task_manager/task_manager.h>

Parameters
[in]handlethe handle id of task to be stopped.
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_unicast ( int  handle,
tm_msg_t send_msg,
tm_msg_t reply_msg,
int  timeout 
)

Request to send messages to the task.

#include <task_manager/task_manager.h>
task_manager_unicast can be used with SYNC and ASYNC mode.
With SYNC mode, reply msg can be sent through task_manager_reply_unicast API.

Parameters
[in]handlethe handle id of task to be sent
[in]send_msgmessage structure to be unicasted
[out]reply_msgthe reply msg structure for sync. If this is NULL, task_manager_unicast works asynchronously.
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
If reply is not NULL(=SYNC), timeout should not be set to TM_NO_RESPONSE.
When you enable CONFIG_TASK_MANAGER_UNICAST_REPLY_TIMEOUT with non-zero value, task manager waits the reply during
CONFIG_TASK_MANAGER_UNICAST_REPLY_TIMEOUT even if user calls this API with TM_RESPONSE_WAIT_INF.
When set to zero, task manager waits the reply forever, it can cause task manager hang.
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_unregister ( int  handle,
int  timeout 
)

Request to unregister a task.

#include <task_manager/task_manager.h>

Parameters
[in]handlethe handle id of task to be unregistered
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0
int task_manager_unset_broadcast_cb ( int  msg,
int  timeout 
)

Unregister callback function which was used for a certain broadcast message.

#include <task_manager/task_manager.h>

Parameters
[in]msgthe broadcast message corresponding to the callback function to be unregistered
[in]timeoutreturnable flag. It can be one of the below.
TM_NO_RESPONSE : Ignore the response of request from task manager
TM_RESPONSE_WAIT_INF : Blocked until get the response from task manager
integer value : Specifies an upper limit on the time for which will block in milliseconds
Returns
On success, OK is returned. On failure, defined negative value is returned.
Since
TizenRT v2.0