当前位置: 首页 > news >正文

网站流量高iis如何做负载均衡专业外贸制作网站

网站流量高iis如何做负载均衡,专业外贸制作网站,wordpress 点点模版,搭建网站免费空间CMSIS 2.0接口中的消息(Message)功能主要涉及到实时操作系统(RTOS)中的线程间通信。在CMSIS 2.0标准中,消息通常是通过消息队列(MessageQueue)来进行处理的,以实现不同线程之间的信息…

CMSIS 2.0接口中的消息(Message)功能主要涉及到实时操作系统(RTOS)中的线程间通信。在CMSIS 2.0标准中,消息通常是通过消息队列(MessageQueue)来进行处理的,以实现不同线程之间的信息交换。

注意事项

在使用CMSIS 2.0的消息队列API时,需要确保在RTOS内核启动之前(即在调用osKernelStart()之前)创建并初始化消息队列。

发送和接收消息时,需要确保传递的指针和缓冲区是有效的,并且大小与创建消息队列时指定的参数相匹配。

如果在超时时间内无法发送或接收消息,函数将返回相应的错误状态。开发人员需要根据这些状态来处理可能的错误情况。

MessageQueue API

API名称

说明

osMessageQueueNew

创建和初始化一个消息队列

osMessageQueueGetName

返回指定的消息队列的名字

osMessageQueuePut

向指定的消息队列存放1条消息,如果消息队列满了,那么返回超时

osMessageQueueGet

从指定的消息队列中取得1条消息,如果消息队列为空,那么返回超时

osMessageQueueGetCapacity

获得指定的消息队列的消息容量

osMessageQueueGetMsgSize

获得指定的消息队列中可以存放的最大消息的大小

osMessageQueueGetCount

获得指定的消息队列中当前的消息数

osMessageQueueGetSpace

获得指定的消息队列中还可以存放的消息数

osMessageQueueReset

将指定的消息队列重置为初始状态

osMessageQueueDelete

删除指定的消息队列

代码编写

修改D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\BUILD.gn文件

# Copyright (c) 2023 Beijing HuaQing YuanJian Education Technology Co., Ltd
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. import("//build/lite/config/component/lite_component.gni")lite_component("demo") {features = [#"base_00_helloworld:base_helloworld_example",#"base_01_led:base_led_example",#"base_02_loopkey:base_loopkey_example",#"base_03_irqkey:base_irqkey_example",#"base_04_adc:base_adc_example",#"base_05_pwm:base_pwm_example",#"base_06_ssd1306:base_ssd1306_example",#"kernel_01_task:kernel_task_example",#"kernel_02_timer:kernel_timer_example",#"kernel_03_event:kernel_event_example",#"kernel_04_mutex:kernel_mutex_example",#"kernel_05_semaphore_as_mutex:kernel_semaphore_as_mutex_example",#"kernel_06_semaphore_for_sync:kernel_semaphore_for_sync_example",#"kernel_07_semaphore_for_count:kernel_semaphore_for_count_example","kernel_08_message_queue:kernel_message_queue_example",]
}

创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\kernel_08_message_queue文件夹

文件夹中创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\kernel_08_message_queue\kernel_message_queue_example.c文件D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\kernel_08_message_queue\BUILD.gn文件

# Copyright (c) 2023 Beijing HuaQing YuanJian Education Technology Co., Ltd
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. static_library("kernel_message_queue_example") {sources = ["kernel_message_queue_example.c"]include_dirs = ["//utils/native/lite/include","//kernel/liteos_m/kal/cmsis",]
}
/** Copyright (C) 2023 HiHope Open Source Organization .* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/#include <stdio.h>
#include <unistd.h>#include "ohos_init.h"
#include "cmsis_os2.h"#define STACK_SIZE   (1024)
#define DELAY_TICKS_3   (3)
#define DELAY_TICKS_5   (5)
#define DELAY_TICKS_20 (20)
#define DELAY_TICKS_80 (80)#define QUEUE_SIZE 3
typedef struct {osThreadId_t tid;int count;
} message_entry;
osMessageQueueId_t qid;void sender_thread(void)
{// 定义一个静态变量count,用于记录发送的消息的次数static int count = 0;// 定义一个message_entry类型的变量sentrymessage_entry sentry;// 无限循环while (1) {// 将当前线程的ID赋值给sentry的tidsentry.tid = osThreadGetId();// 将count的值赋值给sentry的countsentry.count = count;// 打印当前线程的名字和count的值printf("[Message Test] %s send %d to message queue.\r\n",osThreadGetName(osThreadGetId()), count);// 将sentry放入消息队列中osMessageQueuePut(qid, (const void *)&sentry, 0, osWaitForever);// count加1count++;// 延时5个节拍osDelay(DELAY_TICKS_5);}
}void receiver_thread(void)
{// 定义一个消息队列rentrymessage_entry rentry;// 无限循环while (1) {// 从队列qid中获取消息osMessageQueueGet(qid, (void *)&rentry, NULL, osWaitForever);// 打印当前线程名称、接收到的消息计数和发送线程名称printf("[Message Test] %s get %d from %s by message queue.\r\n",osThreadGetName(osThreadGetId()), rentry.count, osThreadGetName(rentry.tid));// 延时3个时钟周期osDelay(DELAY_TICKS_3);}
}osThreadId_t newThread(char *name, osThreadFunc_t func, char *arg)
{osThreadAttr_t attr = {name, 0, NULL, 0, NULL, STACK_SIZE*2, osPriorityNormal, 0, 0};osThreadId_t tid = osThreadNew(func, (void *)arg, &attr);if (tid == NULL) {printf("[Message Test] osThreadNew(%s) failed.\r\n", name);} else {printf("[Message Test] osThreadNew(%s) success, thread id: %d.\r\n", name, tid);}return tid;
}void rtosv2_msgq_main(void)
{qid = osMessageQueueNew(QUEUE_SIZE, sizeof(message_entry), NULL);osThreadId_t ctid1 = newThread("recevier1", receiver_thread, NULL);osThreadId_t ctid2 = newThread("recevier2", receiver_thread, NULL);osThreadId_t ptid1 = newThread("sender1", sender_thread, NULL);osThreadId_t ptid2 = newThread("sender2", sender_thread, NULL);osThreadId_t ptid3 = newThread("sender3", sender_thread, NULL);osDelay(DELAY_TICKS_20);uint32_t cap = osMessageQueueGetCapacity(qid);printf("[Message Test] osMessageQueueGetCapacity, capacity: %u.\r\n", cap);uint32_t msg_size =  osMessageQueueGetMsgSize(qid);printf("[Message Test] osMessageQueueGetMsgSize, size: %u.\r\n", msg_size);uint32_t count = osMessageQueueGetCount(qid);printf("[Message Test] osMessageQueueGetCount, count: %u.\r\n", count);uint32_t space = osMessageQueueGetSpace(qid);printf("[Message Test] osMessageQueueGetSpace, space: %u.\r\n", space);osDelay(DELAY_TICKS_80);osThreadTerminate(ctid1);osThreadTerminate(ctid2);osThreadTerminate(ptid1);osThreadTerminate(ptid2);osThreadTerminate(ptid3);osMessageQueueDelete(qid);
}static void MessageTestTask(void)
{osThreadAttr_t attr;attr.name = "rtosv2_msgq_main";attr.attr_bits = 0U;attr.cb_mem = NULL;attr.cb_size = 0U;attr.stack_mem = NULL;attr.stack_size = STACK_SIZE;attr.priority = osPriorityNormal;if (osThreadNew((osThreadFunc_t)rtosv2_msgq_main, NULL, &attr) == NULL) {printf("[MessageTestTask] Falied to create rtosv2_msgq_main!\n");}
}
APP_FEATURE_INIT(MessageTestTask);

使用build,编译成功后,使用upload进行烧录。

http://www.yayakq.cn/news/483434/

相关文章:

  • 湖南网站建设哪家专业电子工程职业学院
  • 怎么提交网站网站建站基本要素
  • 合肥市城乡建设局网站如何在google上免费推广
  • 什么网站可以免费做视频软件网站建设需要内容
  • 建站吗官方网站研究网站开发意义
  • html在线编写网站天津做网站哪个公司好
  • 国外有哪些设计网站有哪些问题郑州百度快照优化
  • 企业信息系统的作用南通网站优化
  • 做阿里巴巴网站需要多少钱网站建设会遇到哪些难题
  • 高平市网站建设公司知彼网络网站建设
  • 京东网站的设计特点百合怎么做网站
  • html购物网站模板下载电子商务网站开发与设计报告
  • 上饶招聘网站建设公司上海猎头公司收费标准
  • 做的网站怎样评估价值工具类网站做排名
  • 企业网站开发 外文文献会员卡管理系统设计
  • 3d网站开发成本宁波奉化建设局网站
  • 网站建设需要方案凡科网代理登录
  • 杭州兼职网站建设舟山网页设计
  • 网站3d展示怎么做全国注册室内设计师网
  • 国家建设厅网站设计网站的一般过程
  • 网站建设选择数据库wordpress怎么跟vue
  • 网站佣金怎么做会计分录王者荣誉网站怎么做
  • 建公司网站步骤岳阳棋牌软件定制开发公司
  • wordpress15天教网站优化公司上海
  • 江西app网站建设手机软件开发培训班
  • 比较好的做网站创做阿里巴巴网站流程
  • 做结婚视频储存网站wordpress layer
  • devexpress网站开发58同城网站模板下载
  • wordpress使用新浪图床郑州厉害的seo顾问
  • 胶州国际网站建设效果深圳做网站网络营销公司