基本概念
抢占式的调度机制;一共有32个优先级,
高优先级可以抢占低优先级,就是说优先级高的可以插队。
OpenHarmony内核的进程一共有32个优先级(0-31),用户进程可配置的优先级有22个(10-31),最高优先级为10,最低优先级为31。
用户的根进程由内核态创建,其他的都是根进程创建出来的。
- Ready→Running:进程创建后进入就绪态,发生进程切换时,就绪列表中最高优先级的进程被执行,从而进入运行态。若此时该进程中已无其它线程处于就绪态,则该进程从就绪列表删除,只处于运行态;若此时该进程中还有其它线程处于就绪态,则该进程依旧在就绪队列,此时进程的就绪态和运行态共存。
队列中有两个进程,则高优先级的会处于就绪状态和运行状态两种状态。
主进程或所有线程运行结束后,则处于僵尸状态。
HDF驱动框架
按需求加载、按序加载,也就是按照优先级进行加载
HDF驱动编写
1、头文件的引入
#include "hdf_device_desc.h" // HDF框架对驱动开放相关能力接口的头文件#include "hdf_log.h" // HDF 框架提供的日志接口头文件
- 按序加载(需要驱动为默认加载) 配置文件中的priority(取值范围为整数0到200)是用来表示host和驱动的优先级,不同的host内的驱动,host的priority值越小,驱动加载优先级越高;同一个host内驱动的priority值越小,加载优先级越高。
vendor # 产品解决方案厂商└── huawei # 产品解决方案厂商名称└── wifiiot # 产品名称├── hals # 产品解决方案厂商OS适配├── BUILD.gn # 产品编译脚本└── config.json # 产品配置文件
芯片移植关键步骤

device└── hisilicon # 芯片解决方案厂商名├── common # 芯片解决方案开发板公共部分└── hispark_taurus # 开发板名称├── BUILD.gn # 开发板编译入口├── hals # 芯片解决方案厂商OS硬件适配├── linux # linux版本│ └── config.gni # linux版本编译工具链和编译选项配置└── liteos_a # liteos-a版本└── config.gni # liteos_a版本编译工具链和编译选项配置
OpenHarmony Toolchain for Mini and Small System
Build System: ubuntu 18.04
| Name | Version | How to Obtain |
|---|---|---|
| curl | apt-get install curl -y | |
| wget | apt-get install wget -y | |
| python3.8 | apt-get install python3.8 -y | |
| python3-pip | apt-get install python3-pip -y | |
| dosfstools | apt-get install dosfstools -y | |
| mtools | apt-get install mtools -y | |
| scons | apt-get install scons -y | |
| make | apt-get install make -y | |
| libffi-dev | apt-get install libffi-dev -y | |
| zip | apt-get install zip -y | |
| python3-distutils | apt-get install python3-distutils -y | |
| binutils | apt-get install binutils -y | |
| mtd-utils | apt-get install mtd-utils -y | |
| libc6-dev-x32 | apt-get install libc6-dev-x32 -y | |
| tzdata | DEBIAN_FRONTEND=”noninteractive” TZ=”America/New_York” apt-get -y install tzdata | |
| default-jre | apt-get install default-jre -y | |
| default-jdk | apt-get install default-jdk -y | |
| build-essential | apt-get install build-essential | |
| locales | apt-get install locales | |
| setuptools | pip3 install —trusted-host mirrors.aliyun.com -i https://mirrors.aliyun.com/pypi/simple setuptools |
|
| kconfiglib | pip3 install —trusted-host mirrors.aliyun.com -i https://mirrors.aliyun.com/pypi/simple kconfiglib |
|
| pycryptodome | pip3 install —trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple pycryptodome |
|
| ecdsa | pip3 install —trusted-host mirrors.aliyun.com -i https://mirrors.aliyun.com/pypi/simple ecdsa |
|
| llvm | 10.0.1-53907 | https://repo.huaweicloud.com/harmonyos/compiler/clang/10.0.1-53907/linux/llvm.tar.gz |
| hc-gen | 0.65 | https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar |
| gcc_riscv32 | 7.3.0 | https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz |
| ninja | 1.9.0 | https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar |
| gn | 1717 | https://repo.huaweicloud.com/harmonyos/compiler/gn/1717/linux/gn-linux-x86-1717.tar.gz |
| node | v12.20.0 | https://mirrors.huaweicloud.com/nodejs/v12.20.0/node-v12.20.0-linux-x64.tar.gz |
| hmos_app_packing_tool | https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar | |
| hapsigntoolv2 | https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar | |
| hb | python3 -m pip install —user ohos-build |
