⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tc005_01_mb.c.svn-base

📁 RT-Thread是发展中的下一代微内核嵌入式实时操作系统
💻 SVN-BASE
字号:
/* * File      : tc001_thread.c * This file is part of RT-Thread RTOS * COPYRIGHT (C) 2006, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://openlab.rt-thread.com/license/LICENSE * * Change Logs: * Date           Author       Notes * 2006-05-28     Bernard      the first version */#include <rtthread.h>char thread1_stack[512];char thread2_stack[512];struct rt_thread thread1;struct rt_thread thread2;struct rt_mailbox mb;char mb_pool[128];char mb_str1[] = "I'm a mail!";char mb_str2[] = "this is another mail!";void thread1_entry(void* parameter){	unsigned char* str;		while (1)	{		rt_kprintf("thread1: try to recv a mail\n");		if (rt_mb_recv(&mb, (rt_uint32*)&str, RT_WAITING_FOREVER) == RT_EOK)		{			rt_kprintf("thread1: get a mail from mailbox, the content:%s\n", str);			rt_thread_delay(100);		}	}}void thread2_entry(void* parameter){	rt_uint8 count;	count = 0;	while (1)	{		count ++;		if (count & 0x1)		{			rt_mb_send(&mb, (rt_uint32)&mb_str1[0]);		}		else		{			rt_mb_send(&mb, (rt_uint32)&mb_str2[0]);		}		rt_thread_delay(200);	}}int rt_application_init(){	rt_mb_init(&mb, "mbt", &mb_pool[0], 128 / 4, RT_IPC_FLAG_FIFO);	rt_thread_init(&thread1,		"thread1",		thread1_entry, RT_NULL,		&thread1_stack[0], sizeof(thread1_stack),		200, 100);		rt_thread_init(&thread2,		"thread2",		thread2_entry, RT_NULL,		&thread2_stack[0], sizeof(thread2_stack),		250, 75);		rt_thread_startup(&thread1);	rt_thread_startup(&thread2);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -