首先来看看task的数据类型声明,在config\include\hal\task_config.h中对task和module类型进行了定义。

/*************************************************************************
* STRUCT
* task_info_struct
*
* DESCRIPTION
* The structure defines component task information at execution time
*
* FIELDS
* task_name_ptr - pointer to task name
* task_qname_ptr; - pointer to task external queue name
* task_priority - task priority
* task_stack_size - task stack size
* task_id - created task entity id
* task_ext_qid - created task external queue id
* task_int_qid_ptr - pointer to created task internal queue
* task_entry_func - task's entry function
* task_cfg_func - task's configuration handler
* task_init_func - task's initialization handler
* task_reset_func - task's reset handler
* task_end_func - task's termination handler
* task_ext_qsize - task's external queue size
*
* GLOBALS AFFECTED
*
*************************************************************************/
typedef struct {
kal_char *task_name_ptr;
kal_char *task_qname_ptr;
kal_uint32 task_priority;
kal_uint32 task_stack_size;
kal_taskid task_id;
kal_msgqid task_ext_qid;
int_q_type *task_int_qid_ptr;
kal_task_func_ptr task_entry_func;
task_cfg_func_ptr task_cfg_func;
task_init_func_ptr task_init_func;
task_reset_func_ptr task_reset_func;
task_end_func_ptr task_end_func;
kal_uint8 task_ext_qsize;
kal_uint8 task_int_qsize;
#ifdef __SYS_INTERN_RAM__
kal_bool task_internal_ram_stack;
#endif /* __SYS_INTERN_RAM__ */
} task_info_struct;
typedef struct {
task_indx_type module_task_indx;
mod_init_func_ptr module_init[ RPS_MAX_MODULES_IN_TASK ];
mod_cfg_func_ptr module_configure[ RPS_MAX_MODULES_IN_TASK ];
} module_info_struct;
/*************************************************************************
* STRUCT
* syscomp_info_struct
*
* DESCRIPTION
* The structure defines component task configuration information
*
* FIELDS
* comp_name_ptr - pointer to component task name
* comp_qname_ptr - pointer to component task's external queue name
* comp_priority - component task's priority
* comp_stack_size - component task's stack size
* comp_ext_qsize - component task's external queue size
* comp_int_qsize - component task's internal queue size
* comp_create_func- component entity's create function
*
* GLOBALS AFFECTED
*
*************************************************************************/
typedef struct {
kal_char *comp_name_ptr;
kal_char *comp_qname_ptr;
kal_uint32 comp_priority;
kal_uint32 comp_stack_size;
kal_create_func_ptr comp_create_func;
kal_bool comp_internal_ram_stack;
kal_uint8 comp_ext_qsize;
kal_uint8 comp_int_qsize;
kal_uint8 comp_boot_mode;
} comptask_info_struct;

全局的task数组在task_config.c中定义为task_info_g,在stack_init_comp_info()中申请空间(kal_sys_mem_alloc)并初始化。数组的大小为enum类型RPS_TOTAL_STACK_TASKS,这个值由hal_task_config.h和app_task_config.h决定。这两个文件中,每个枚举量都是一个task_index。数组的值从sys_comp_config_tbl传递过来,这个数组在syscomp_config.c中定义,同样由hal_task_config.h和app_task_config.h决定。

在 stack_config.h中

#define task_index(p1) p1,
typedef enum {
#include "hal_task_config.h"
#include "app_task_config.h"
/*Total number of build time tasks*/
RPS_TOTAL_STACK_TASKS,
}task_indx_type;

例如

在app_task_config.h中

/*************************Task CFG Begin****************/
/*task_indx_type*/
task_index(INDX_MMS)
/*WAP ps task*/
/*module_type and mod_task_g*/
task_module_map(INDX_MMS, MOD_MMS) /*task's parameters*/
task_name("MMS")
task_queue_name("MMS Q")
task_priority(TASK_PRIORITY_MMS)
task_stack_size()
#ifdef OBIGO_Q03C_MMS_V02
task_create_function(mms_create)
#else
null_task_create_entry(NULL)
#endif
task_stack_internalRAM(KAL_FALSE)
task_external_queue_size()
task_internal_queue_size()
task_boot_mode(NORMAL_M)
/*************************Task CFG END******************/

或者在~flash_cfg_tmp.c也可以看到

 typedef enum {
#line 1 "config\\include\\hal\\hal_task_config.h"
#line 1613 "config\\include\\hal\\hal_task_config.h"
INDX_NIL,
...
 INDX_MMS,
...
INDX_USER_EXT5,
INDX_TEST_TASK_MBTK,
INDX_TEST_TASK_MBTK2,
INDX_TEST_TASK_MBTK3,
#line 3281 "config\\include\\app\\app_task_config.h"
#line 1204 "config\\include\\hal\\stack_config.h"
RPS_TOTAL_STACK_TASKS,
}task_indx_type;
/*************************************************************************
* STRUCT
* syscomp_info_struct
*
* DESCRIPTION
* The structure defines component task configuration information
*
* FIELDS
* comp_name_ptr - pointer to component task name
* comp_qname_ptr - pointer to component task's external queue name
* comp_priority - component task's priority
* comp_stack_size - component task's stack size
* comp_ext_qsize - component task's external queue size
* comp_int_qsize - component task's internal queue size
* comp_create_func- component entity's create function
*
* GLOBALS AFFECTED
*
*************************************************************************/
typedef struct {
kal_char *comp_name_ptr;//<Task名称
kal_char *comp_qname_ptr;//<外部队列名称
kal_uint32 comp_priority;//<Task优先级
kal_uint32 comp_stack_size;//<Task堆栈大小
kal_create_func_ptr comp_create_func;//<创建Task的入口函数,返回kal_bool类型,要求参数为comptask_handler_struct **,定义见下方。
kal_bool comp_internal_ram_stack;//<暂不知道作何用处,一般为KAL_FALSE
kal_uint8 comp_ext_qsize;//<外部队列大小
kal_uint8 comp_int_qsize;//<内部队列大小
kal_uint8 comp_boot_mode;
} comptask_info_struct;

/*************************************************************************
* STRUCT
* syscomp_info_struct
*
* DESCRIPTION
* The structure defines component task configuration information
*
* FIELDS
* comp_entry_func - component task's entry function
* comp_cfg_func - component task's configurantion handler
* comp_init_func - component task's initialization handler
* comp_reset_func - component task's reset handler
* comp_end_func - component task's termination handler
* comp_modmain_func - component task's module main handler
*
* GLOBALS AFFECTED
*
*************************************************************************/
typedef struct {
kal_task_func_ptr comp_entry_func;//<主函数,实现为一个消息循环
task_init_func_ptr comp_init_func;//<初始化函数
task_cfg_func_ptr comp_cfg_func;//<配置函数
task_reset_func_ptr comp_reset_func;//<重置函数
task_end_func_ptr comp_end_func;//<Task结束时调用
} comptask_handler_struct; typedef kal_bool (*kal_create_func_ptr)(comptask_handler_struct **);

const comptask_info_struct sys_comp_config_tbl[RPS_TOTAL_STACK_TASKS] =
{
#include "hal_task_config.h"
#include "app_task_config.h"
};
#define task_name(p1)                       {p1,
#define task_queue_name(p1) p1,
#define task_priority(p1) p1,
#define task_stack_size(p1) (p1 + TASK_STACK_COMMON_PLUS),
#define null_task_create_entry(p1) (kal_create_func_ptr)TASK_NO_CREATE_PATTERN,
#define task_create_function(p1) p1,
#define task_stack_internalRAM(p1) p1,
#define task_external_queue_size(p1) p1,
#define task_internal_queue_size(p1) p1,
#define task_boot_mode(p1) p1},
/*************************Task CFG Begin****************/
/*task_indx_type*/
task_index(INDX_MMI)
/*module_type and mod_task_g*/
#ifdef WISDOM_MMI
/* under construction !*/
/* under construction !*/
#else
task_module_map(INDX_MMI, MOD_MMI)
#endif
/* MOD_MMI is used by HAL file, please don't delete or modify it */ /*task's parameters*/
task_name("MMI")
task_queue_name("MMI Q")
task_priority(TASK_PRIORITY_MMI) #if defined(NEPTUNE_MMI)
#if defined(__LOW_COST_SUPPORT_ULC__)
task_stack_size()
#else /* __LOW_COST_SUPPORT_ULC__ */
task_stack_size()
#endif /* __LOW_COST_SUPPORT_ULC__ */
#else /* Default value */
#if defined(WISDOM_MMI)
#if defined(OPERA_BROWSER) /* MMI: + 4 KB */
/* under construction !*/
#else
/* under construction !*/
#endif
#else /* WISDOM_MMI */
#ifdef __MOBILE_VIDEO_SUPPORT__
task_stack_size()
#else
#if defined(__MRE_PACKAGE_FULL__) || defined(__MRE_PACKAGE_NORMAL__)
task_stack_size() /* MRE APP opera need 16KB */
#elif defined(OPERA_BROWSER) /* MMI: + 4 KB */
task_stack_size()
#else
task_stack_size()
#endif
#endif
#endif /* WISDOM_MMI */
#endif /* NEPTUNE_MMI */
#ifdef MMI_NOT_PRESENT
null_task_create_entry(NULL)
#elif !defined(WISDOM_MMI)
task_create_function(mmi_create)
#else
/* under construction !*/
#endif
task_stack_internalRAM(KAL_FALSE)
#if defined(WISDOM_MMI)
/* under construction !*/
/* under construction !*/
#else
#if (defined(__GEMINI__)) && (GEMINI_PLUS >= 4)
/* under construction !*/
#else
task_external_queue_size()
#endif
task_internal_queue_size()
#endif
task_boot_mode(NORMAL_M | USB_M)
/*************************Task CFG END******************/
/*****************************************************************************
* FUNCTION
* mmi_create
* DESCRIPTION
* MMI task create function for system service.
* PARAMETERS
* handle [IN]
* a(?) [IN/OUT] Handle: provide the create task related routine function.
* RETURNS
* The result is ok or not.
*****************************************************************************/
kal_bool mmi_create(comptask_handler_struct **handle)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/ static comptask_handler_struct mmi_handler_info =
{
MMI_task, /* task entry function */
MMI_Init, /* task initialization function */
NULL,
NULL, /* task reset handler */
NULL, /* task termination handler */
}; /*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
*handle = &mmi_handler_info;
return KAL_TRUE;
}

发送消息

/*
NOTE: User must take care about the usage of this API,
if the message is sent to the same task, the message
will be sent to internal queue, task must process the
internal queue. Otherwise, internal queue will full.
*/
#define SEND_ILM( src_mod, dest_mod, sap, ilm_ptr)\
{ \
ilm_ptr->src_mod_id = src_mod; \
ilm_ptr->dest_mod_id = dest_mod; \
ilm_ptr->sap_id = sap; \
if (mod_task_g[src_mod] == mod_task_g[dest_mod]) { \
msg_send_int_queue(ilm_ptr); \
} else { \
msg_send_ext_queue(ilm_ptr); \
} \
}

【手记】MTK之TASK创建及使用的更多相关文章

  1. # C# 中的Task创建指南

    本文还处于草稿阶段,难免还有错误修改改正,逻辑还不是很清晰,笔者会努力完善,长期更新! [0000] 前言 标题起得有些"大",意在集大家的力量,总结出来一份关于Task相对&qu ...

  2. 【手记】解决“未能创建 SSL/TLS 安全通道”异常

    之前写了一个桌面程序,程序会间歇性访问某个https接口,一直用的好好的,今天突然报错了,异常就发生在访问接口的地方,曰“请求被中止,未能创建 SSL/TLS 安全通道.”,另外有台电脑也有跑该程序, ...

  3. 【学习随手记】kubeadm 查看创建集群需要的镜像版本,附拉取镜像脚本

    查看创建集群需要的镜像版本 kubeadm config images list [--kubernetes-version <version>] 国内拉取镜像脚本 一般而言,直接使用ku ...

  4. Microsoft Porject Online 学习随手记一:环境创建和数据导入

    没有想像的简单,也没那么复杂 Project OL之前是Dynamics 365 Enterprise P1中的一个模块,目前最新版本只能简单创建并且已经没有Enterprise P1选项. 主要流程 ...

  5. [BI项目记]-新任务创建

    上一篇介绍了如何处理一个Bug工作,此篇主要介绍如何借助TFS对于一个新需求创建一个新的工作项. 这里假定,有一个新的需求,需要创建五个报表. 然后开发的工作流程如下: 这个流程总结起来大致如下: 首 ...

  6. 5天玩转C#并行和多线程编程 —— 第三天 认识和使用Task

    5天玩转C#并行和多线程编程系列文章目录 5天玩转C#并行和多线程编程 —— 第一天 认识Parallel 5天玩转C#并行和多线程编程 —— 第二天 并行集合和PLinq 5天玩转C#并行和多线程编 ...

  7. C# Task 用法

    C# Task 的用法 其实Task跟线程池ThreadPool的功能类似,不过写起来更为简单,直观.代码更简洁了,使用Task来进行操作.可以跟线程一样可以轻松的对执行的方法进行控制. 顺便提一下, ...

  8. ABP入门系列(5)——创建应用服务

    一.解释下应用服务层 应用服务用于将领域(业务)逻辑暴露给展现层.展现层通过传入DTO(数据传输对象)参数来调用应用服务,而应用服务通过领域对象来执行相应的业务逻辑并且将DTO返回给展现层.因此,展现 ...

  9. 【ANT】Ant常用的内置task

    ant 例如: <target name="callProjectB"> <echo message="In projectA calling proj ...

随机推荐

  1. springboot入门1

    1引入springboot父依赖,和 spring-boot-starter-web的启动器 依赖引入后jar包展示依赖的情况 入门工程  配置数据源 package com.boot.web.con ...

  2. [Java] 基本資料包裝類別 Wrapper Classes

    基本型別包裝 (Wrapper Classes) 將基本型別生成物件,要將基本型別先包裝成物件,才能執行生成, Boxing: Integer a = new Integer(1) Unboxing: ...

  3. 使用dotenv 管理nodejs 应用的环境变量&&docker-compose 运行

      说明dotenv 是一个很方便的符合12 factor 的环境变量管理工具,使用很方便,实际上里面的代码也不是很多 测试使用docker 进行环境部署,为了方便分发使用pkg 进行打包,使用alp ...

  4. Vector Math for 3D Computer Graphics (Bradley Kjell 著)

    https://chortle.ccsu.edu/VectorLessons/index.html Chapter0 Points and Lines (已看) Chapter1 Vectors, P ...

  5. freemaker学习

    1,依赖 <!-- Spring Boot Freemarker 依赖 --><dependency> <groupId>org.springframework.b ...

  6. H3C交换机IRF典型配置举例LACP MAD检测方式

    一.组网需求 由于公司人员激增,接入层交换机提供的端口数目已经不能满足PC的接入需求.现需要在保护现有投资的基础上扩展端口接入数量,并要求网络易管理.易维护. 二.组网图 三.配置思路 Device ...

  7. Linux shell 重定向学习笔记

    在了解重定向之前,我们先来看看linux 的文件描述符. linux文件描述符:可以理解为linux跟踪打开文件,而分配的一个数字,这个数字有点类似c语言操作文件时候的句柄,通过句柄就可以实现文件的读 ...

  8. 异常:tomcat与windows时间不同步

    调试一个项目时发现用户那里服务器的Tomcat命令行中log4j输出的时间与操作系统时间不一致,因此日志记录的时间与操作系统时间也不一致,且正好相差8个小时.产生原因是因为Tomcat中的时区设置与操 ...

  9. 浏览器打开aspx文件 ,提示:XML 解析错误:找不到根元素

    在使用VS2013这个IDE创建aspx文件后,在浏览器打开后居然发现了以下错误:XML 解析错误:找不到根元素         详细查看里面的信息,发现了这么一个链接位置:http://localh ...

  10. SSD硬盘测速较低的原因备忘

    SATA3 SSD测速度盘速度只有200MB/s,可能原因有: 原因分为几种:没开AHCI 没有4K对齐 虽然接的是SATA3接口但SATA3有分为3G和6G这些传输速度接口的分别,同理SATA线3G ...