178 Star 837 Fork 332

GVP腾讯开源 / TencentOS-tiny

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.c 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
daishengdong 提交于 2020-04-16 15:53 . fix sample code
#include "tos_k.h"
#include "mcu_init.h"
#define STK_SIZE_TASK_WIZARD 512
#define STK_SIZE_TASK_WARRIOR 512
k_stack_t stack_task_wizard[STK_SIZE_TASK_WIZARD];
k_stack_t stack_task_warrior_0[STK_SIZE_TASK_WARRIOR];
k_stack_t stack_task_warrior_1[STK_SIZE_TASK_WARRIOR];
k_stack_t stack_task_warrior_2[STK_SIZE_TASK_WARRIOR];
k_task_t task_wizard;
k_task_t task_warrior_0;
k_task_t task_warrior_1;
k_task_t task_warrior_2;
k_countdownlatch_t countdownlatch;
void entry_task_warrior_0(void *arg)
{
printf("warrior 0: I have done my job\n");
tos_countdownlatch_post(&countdownlatch);
}
void entry_task_warrior_1(void *arg)
{
printf("warrior 1: I have done my job\n");
tos_countdownlatch_post(&countdownlatch);
}
void entry_task_warrior_2(void *arg)
{
printf("warrior 2: I have done my job\n");
tos_countdownlatch_post(&countdownlatch);
}
void entry_task_wizard(void *arg)
{
printf("wizard: I will set 3 warriors to find the fragments\n");
tos_countdownlatch_create(&countdownlatch, 3);
(void)tos_task_create(&task_warrior_0, "warrior_0", entry_task_warrior_0, NULL,
4, stack_task_warrior_0, STK_SIZE_TASK_WARRIOR, 0);
(void)tos_task_create(&task_warrior_1, "warrior_1", entry_task_warrior_1, NULL,
4, stack_task_warrior_1, STK_SIZE_TASK_WARRIOR, 0);
(void)tos_task_create(&task_warrior_2, "warrior_2", entry_task_warrior_2, NULL,
4, stack_task_warrior_2, STK_SIZE_TASK_WARRIOR, 0);
printf("wizard: now warriors are on their way, I will wait here until they all done the job\n");
tos_countdownlatch_pend(&countdownlatch);
printf("wizard: the warriors all have done their jobs, let's make the weapon\n");
}
int main(void)
{
board_init();
tos_knl_init();
(void)tos_task_create(&task_wizard, "wizard", entry_task_wizard, NULL,
3, stack_task_wizard, STK_SIZE_TASK_WIZARD, 0);
tos_knl_start();
}
C
1
https://gitee.com/Tencent/TencentOS-tiny.git
git@gitee.com:Tencent/TencentOS-tiny.git
Tencent
TencentOS-tiny
TencentOS-tiny
master

搜索帮助