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

wordpress首页文件网站seo优化徐州百度网络

wordpress首页文件,网站seo优化徐州百度网络,网站源代码编辑,做网站从哪里做CMSIS 2.0接口中的Mutex(互斥锁)是用于在多线程环境中保护共享资源的访问机制。Mutex(互斥锁)是一种特殊的信号量,用于确保同一时间只有一个线程可以访问特定的共享资源。 在嵌入式系统或多线程应用中,当多…

CMSIS 2.0接口中的Mutex(互斥锁)是用于在多线程环境中保护共享资源的访问机制。Mutex(互斥锁)是一种特殊的信号量,用于确保同一时间只有一个线程可以访问特定的共享资源。 在嵌入式系统或多线程应用中,当多个线程需要访问同一资源时,如果没有适当的同步机制,可能会导致数据不一致或其他问题。Mutex就是用来解决这类问题的。这些函数通常不能在中断服务程序(ISR)中调用,因为中断的上下文可能与这些函数的设计不符。 在使用Mutex时,必须确保正确地获取和释放锁,以避免死锁或其他同步问题。

Mutex API

API名称

说明

osMutexNew

创建并初始化一个互斥锁

osMutexGetName

获得指定互斥锁的名字

osMutexAcquire

获得指定的互斥锁的访问权限,若互斥锁已经被锁,则返回超时

osMutexRelease

释放指定的互斥锁

osMutexGetOwner

获得指定互斥锁的所有者线程

osMutexDelete

删除指定的互斥锁

代码编写

修改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",]
}

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

文件夹中创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\kernel_04_mutex\kernel_mutex_example.c文件D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\kernel_04_mutex\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_mutex_example") {sources = ["kernel_mutex_example.c"]include_dirs = ["//utils/native/lite/include","//kernel/liteos_m/kal/cmsis",]
}
/** 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.*/#include <stdio.h>
#include <unistd.h>#include "ohos_init.h"
#include "cmsis_os2.h"osThreadId_t Task1_ID; //  任务1 ID
osThreadId_t Task2_ID; //  任务2 ID
osMutexId_t Mutex_ID;       // 定义互斥锁 ID
uint8_t buff[20] = {0};    // 定义一个共享资源
#define TASK_STACK_SIZE 1024
#define TASK_DELAY_TIME 1 // s/*** @description: 任务1* @param {*}* @return {*}*/
void Task1(void)
{int i = 0;printf("enter Task 1.......\n");while (1) {osMutexAcquire(Mutex_ID, osWaitForever);    // 请求互斥锁// 操作共享数据 写数据printf("write Buff Data: \n");for (i = 0; i < sizeof(buff); i++) {buff[i] = i;}printf("\n");osMutexRelease(Mutex_ID);   // 释放互斥锁sleep(TASK_DELAY_TIME);}
}
/*** @description: 任务2* @param {*}* @return {*}*/
void Task2(void)
{int i = 0;printf("enter Task 2.......\n");while (1) {osMutexAcquire(Mutex_ID, osWaitForever);    // 请求互斥锁// 操作共享数据 读数据printf("read Buff Data: \n");for (i = 0; i < sizeof(buff); i++) {printf("%d \n", buff[i]);}printf("\n");osMutexRelease(Mutex_ID);   // 释放互斥锁sleep(TASK_DELAY_TIME);}
}
/*** @description: 初始化并创建任务* @param {*}* @return {*}*/
static void kernel_mutex_example(void)
{printf("Enter kernel_mutex_example()!\n");// 创建互斥锁Mutex_ID = osMutexNew(NULL);if (Mutex_ID != NULL) {printf("ID = %d, Create Mutex_ID is OK!\n", Mutex_ID);}osThreadAttr_t taskOptions;taskOptions.name = "Task1";              // 任务的名字taskOptions.attr_bits = 0;               // 属性位taskOptions.cb_mem = NULL;               // 堆空间地址taskOptions.cb_size = 0;                 // 堆空间大小taskOptions.stack_mem = NULL;            // 栈空间地址taskOptions.stack_size = TASK_STACK_SIZE;           // 栈空间大小 单位:字节taskOptions.priority = osPriorityNormal; // 任务的优先级Task1_ID = osThreadNew((osThreadFunc_t)Task1, NULL, &taskOptions);      // 创建任务1if (Task1_ID != NULL) {printf("ID = %d, Create Task1_ID is OK!\n", Task1_ID);}taskOptions.name = "Task2";              // 任务的名字taskOptions.priority = osPriorityNormal; // 任务的优先级Task2_ID = osThreadNew((osThreadFunc_t)Task2, NULL, &taskOptions);      // 创建任务2if (Task2_ID != NULL) {printf("ID = %d, Create Task2_ID is OK!\n", Task2_ID);}
}
SYS_RUN(kernel_mutex_example);

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

http://www.hkea.cn/news/110010/

相关文章:

  • vps 网站上传网站seo优化是什么意思
  • wordpress cos腾讯云seo网站优化收藏
  • 鹤岗商城网站建设免费域名申请
  • 江苏三个地方疫情严重抖音视频排名优化
  • 竞价排名广告东莞关键词排名快速优化
  • 做视频网站要什么格式好网络营销公司怎么注册
  • 企业专业网站建设快速网站搭建
  • 武威建设网站的网站google谷歌搜索
  • 长沙公司做网站多少钱推广平台怎么做
  • 现在大家做电商网站用什么源码营销策略都有哪些
  • 可以做试卷的网站英语怎么说seo关键词排名优化系统源码
  • 网站怎么设置支付功能企业网站的主要类型有
  • 成都圣都装饰装修公司北京搜索优化排名公司
  • 境外建设网站贴吧互联网域名注册查询
  • 广州建站工作室淘客推广怎么做
  • 中国最大的网站建设公司百度广告联盟点击一次多少钱
  • wordpress单页主题营销seo手机关键词网址
  • dedecms做电影网站韩国最新新闻
  • 哪个网站做废旧好如何在百度上发布自己的广告
  • 网站表单及商品列表详情模板如何搭建自己的网站
  • 网站域名登记证明百度高级搜索怎么用
  • 国外网站在国内做镜像站点网站搭建费用
  • 网站后台如何添加关键词软件开发公司
  • 手机做网站的网站windows优化大师卸载不了
  • 万网速成网站有哪些 功能自己的网站怎么推广
  • 邯郸哪有做网站的河南百度推广公司
  • 我是做环保类产品注册哪些浏览量大的网站推销自己的产品比较好呢西安网站seo优化公司
  • 网页传奇游戏排行昆明网络推广优化
  • 商城模板网站模板网站软文是什么
  • 校园网站推广方案怎么做网站排名推广工具