TizenRT Public API  v2.0 M2
task_manager.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2018 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
28 #ifndef __TASK_MANAGER_H__
29 #define __TASK_MANAGER_H__
30 
31 #include <tinyara/config.h>
32 #include <signal.h>
33 #include <pthread.h>
34 
35 #include <tinyara/task_manager_internal.h>
36 
40 #define TM_APP_STATE_RUNNING (1)
41 #define TM_APP_STATE_PAUSE (2)
42 #define TM_APP_STATE_STOP (3)
43 #define TM_APP_STATE_UNREGISTERED (4)
44 #define TM_APP_STATE_CANCELLING (5)
45 
54 #define TM_APP_PERMISSION_ALL (0)
55 #define TM_APP_PERMISSION_GROUP (1)
56 #define TM_APP_PERMISSION_DEDICATE (2)
57 
63 #define TM_NO_RESPONSE (0)
64 #define TM_RESPONSE_WAIT_INF (-1)
65 
71  TM_ALREADY_STARTED_APP = -1,
72  TM_ALREADY_PAUSED_APP = -2,
73  TM_ALREADY_STOPPED_APP = -3,
74  TM_UNREGISTERED_APP = -4,
75  TM_CANCELLING_APP = -5,
76  TM_OPERATION_FAIL = -6,
77  TM_COMMUCATION_FAIL = -7,
78  TM_BUSY = -8,
79  TM_INVALID_PARAM = -9,
80  TM_INVALID_DRVFD = -10,
81  TM_OUT_OF_MEMORY = -11,
82  TM_NO_PERMISSION = -12,
83  TM_NOT_SUPPORTED = -13,
84  TM_UNREGISTERED_MSG = -14,
85  TM_ALREADY_REGISTERED_CB = -15,
86  TM_REPLY_TIMEOUT = -16,
87  TM_TASK_MGR_NOT_ALIVE = -17,
88 };
89 
98  TM_BROADCAST_WIFI_ON = 1,
99  TM_BROADCAST_WIFI_OFF = 2,
100  TM_BROADCAST_SYSTEM_MSG_MAX,
101 #ifndef CONFIG_TASK_MANAGER_USER_SPECIFIC_BROADCAST
102  TM_BROADCAST_MSG_MAX = TM_BROADCAST_SYSTEM_MSG_MAX,
103 #endif
104 };
108 struct tm_appinfo_s {
109  char *name;
110  int tm_gid;
111  int handle;
112  int status;
113  int permission;
114 };
115 typedef struct tm_appinfo_s tm_appinfo_t;
116 
118  tm_appinfo_t task;
119  struct tm_appinfo_list_s *next;
120 };
121 typedef struct tm_appinfo_list_s tm_appinfo_list_t;
122 
126 struct tm_msg_s {
127  int msg_size;
128  void *msg;
129 };
130 typedef struct tm_msg_s tm_msg_t;
131 
135 typedef void (*_tm_unicast_t)(tm_msg_t *);
136 
140 typedef void (*_tm_broadcast_t)(void *, void *);
141 
145 typedef void (*_tm_termination_t)(void *);
146 
147 #ifdef __cplusplus
148 extern "C" {
149 #endif /* __cplusplus */
150 
151 /****************************************************************************
152  * Public Function Prototypes
153  ****************************************************************************/
168 int task_manager_register_builtin(char *name, int permission, int timeout);
186 int task_manager_register_task(char *name, int priority, int stack_size, main_t entry, char * argv[], int permission, int timeout);
202 int task_manager_register_pthread(char *name, pthread_attr_t *attr, pthread_startroutine_t start_routine, pthread_addr_t arg, int permission, int timeout);
214 int task_manager_unregister(int handle, int timeout);
226 int task_manager_start(int handle, int timeout);
238 int task_manager_stop(int handle, int timeout);
250 int task_manager_pause(int handle, int timeout);
262 int task_manager_resume(int handle, int timeout);
275 int task_manager_restart(int handle, int timeout);
295 int task_manager_unicast(int handle, tm_msg_t *send_msg, tm_msg_t *reply_msg, int timeout);
310 int task_manager_broadcast(int msg, tm_msg_t *data, int timeout);
318 int task_manager_set_unicast_cb(void (*func)(tm_msg_t *data));
333 int task_manager_set_broadcast_cb(int msg, void (*func)(void *user_data, void *data), tm_msg_t *cb_data);
342 int task_manager_set_exit_cb(void (*func)(void *data), tm_msg_t *cb_data);
351 int task_manager_set_stop_cb(void (*func)(void *data), tm_msg_t *cb_data);
364 tm_appinfo_list_t *task_manager_getinfo_with_name(char *name, int timeout);
377 tm_appinfo_t *task_manager_getinfo_with_handle(int handle, int timeout);
390 tm_appinfo_list_t *task_manager_getinfo_with_group(int group, int timeout);
402 tm_appinfo_t *task_manager_getinfo_with_pid(int pid, int timeout);
410 void task_manager_clean_info(tm_appinfo_t **info);
418 void task_manager_clean_infolist(tm_appinfo_list_t **info_list);
426 int task_manager_reply_unicast(tm_msg_t *reply_msg);
446 int task_manager_unset_broadcast_cb(int msg, int timeout);
458 int task_manager_dealloc_broadcast_msg(int msg, int timeout);
459 
460 #ifdef __cplusplus
461 }
462 #endif /* __cplusplus */
463 
464 #endif
465 
int task_manager_unregister(int handle, int timeout)
Request to unregister a task.
int task_manager_register_builtin(char *name, int permission, int timeout)
Request to register a built-in task.
int task_manager_start(int handle, int timeout)
Request to start the task.
int task_manager_stop(int handle, int timeout)
Request to stop the task.
void(* _tm_termination_t)(void *)
Termination callback function type.
Definition: task_manager.h:145
tm_appinfo_list_t * task_manager_getinfo_with_name(char *name, int timeout)
Get task information list through task name.
void(* _tm_broadcast_t)(void *, void *)
Broadcast callback function type.
Definition: task_manager.h:140
tm_appinfo_list_t * task_manager_getinfo_with_group(int group, int timeout)
Get task information list through group.
int task_manager_resume(int handle, int timeout)
Request to resume the task.
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.
tm_appinfo_t * task_manager_getinfo_with_pid(int pid, int timeout)
Get the handle through pid.
void task_manager_clean_info(tm_appinfo_t **info)
Clean task information.
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.
tm_appinfo_t * task_manager_getinfo_with_handle(int handle, int timeout)
Get task information through handle.
void(* _tm_unicast_t)(tm_msg_t *)
Unicast callback function type.
Definition: task_manager.h:135
int task_manager_unset_broadcast_cb(int msg, int timeout)
Unregister callback function which was used for a certain broadcast message.
Application Info Structure.
Definition: task_manager.h:108
int task_manager_set_exit_cb(void(*func)(void *data), tm_msg_t *cb_data)
Set callback function called when task terminates normally.
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.
int task_manager_pause(int handle, int timeout)
Request to pause the task.
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...
void task_manager_clean_infolist(tm_appinfo_list_t **info_list)
Clean task information list.
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.
int task_manager_set_unicast_cb(void(*func)(tm_msg_t *data))
Set unicast callback function API.
int task_manager_restart(int handle, int timeout)
Request to restart the task.
tm_defined_broadcast_msg
Broadcast message list.
Definition: task_manager.h:97
int task_manager_broadcast(int msg, tm_msg_t *data, int timeout)
Request to send messages to the tasks.
tm_result_error_e
Error Type of Result Value returned from Task Manager.
Definition: task_manager.h:70
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>
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...
Unicast message Structure.
Definition: task_manager.h:126
int task_manager_reply_unicast(tm_msg_t *reply_msg)
Send unicast reply message.