2015做哪些網站致富什么是互聯(lián)網營銷
往期知識點記錄:
- 鴻蒙(HarmonyOS)應用層開發(fā)(北向)知識點匯總
- 鴻蒙(OpenHarmony)南向開發(fā)保姆級知識點匯總~
- 子系統(tǒng)開發(fā)內核
- 輕量系統(tǒng)內核(LiteOS-M)
- 輕量系統(tǒng)內核(LiteOS-M)【中斷管理】
- 輕量系統(tǒng)內核(LiteOS-M)【任務管理】
- 輕量系統(tǒng)內核(LiteOS-M)【內存管理】
- 輕量系統(tǒng)內核(LiteOS-M)【內核通信機制】
- 輕量系統(tǒng)內核(LiteOS-M)【時間管理】
- 輕量系統(tǒng)內核(LiteOS-M)【擴展組件】
- 輕量系統(tǒng)內核(LiteOS-M)【內存調測】
- 輕量系統(tǒng)內核(LiteOS-M)【異常調測】
- 輕量系統(tǒng)內核(LiteOS-M)【Trace調測】
- 輕量系統(tǒng)內核(LiteOS-M)【LMS調測】
- 輕量系統(tǒng)內核(LiteOS-M)【SHELL】
- 小型系統(tǒng)內核(LiteOS-A)【概述】
- 小型系統(tǒng)內核(LiteOS-A)【內核啟動】
- 小型系統(tǒng)內核(LiteOS-A)【中斷及異常處理】
- 標準系統(tǒng)內核(Linux)【New IP內核協(xié)議?!?/li>
- 標準系統(tǒng)內核(Linux)【內核增強特性 > 任務調度】
- 持續(xù)更新中……
系統(tǒng)調用
基本概念
OpenHarmony LiteOS-A實現(xiàn)了用戶態(tài)與內核態(tài)的區(qū)分隔離,用戶態(tài)程序不能直接訪問內核資源,而系統(tǒng)調用則為用戶態(tài)程序提供了一種訪問內核資源、與內核進行交互的通道。
運行機制
如圖1所示,用戶程序通過調用System API(系統(tǒng)API,通常是系統(tǒng)提供的POSIX接口)進行內核資源訪問與交互請求,POSIX接口內部會觸發(fā)SVC/SWI異常,完成系統(tǒng)從用戶態(tài)到內核態(tài)的切換,然后對接到內核的Syscall Handler(系統(tǒng)調用統(tǒng)一處理接口)進行參數(shù)解析,最終分發(fā)至具體的內核處理函數(shù)。
圖1?系統(tǒng)調用示意圖
Syscall Handler的具體實現(xiàn)在kernel/liteos_a/syscall/los_syscall.c中OsArmA32SyscallHandle函數(shù),在進入系統(tǒng)軟中斷異常時會調用此函數(shù),并且按照kernel/liteos_a/syscall/syscall_lookup.h中的清單進行系統(tǒng)調用的入?yún)⒔馕?#xff0c;執(zhí)行各系統(tǒng)調用最終對應的內核處理函數(shù)。
說明:
系統(tǒng)調用提供基礎的用戶態(tài)程序與內核的交互功能,不建議開發(fā)者直接使用系統(tǒng)調用接口,推薦使用內核提供的對外POSIX接口,若需要新增系統(tǒng)調用接口,詳見開發(fā)指導。
內核向用戶態(tài)提供的系統(tǒng)調用接口清單詳見kernel/liteos_a/syscall/syscall_lookup.h,內核相應的系統(tǒng)調用對接函數(shù)清單詳見kernel/liteos_a/syscall/los_syscall.h。
開發(fā)指導
開發(fā)流程
新增系統(tǒng)調用的典型開發(fā)流程如下:
- 在LibC庫中確定并添加新增的系統(tǒng)調用號。
- 在LibC庫中新增用戶態(tài)的函數(shù)接口聲明及實現(xiàn)。
- 在內核系統(tǒng)調用頭文件中確定并添加新增的系統(tǒng)調用號及對應內核處理函數(shù)的聲明。
- 在內核中新增該系統(tǒng)調用對應的內核處理函數(shù)。
編程實例
示例代碼:
- 在LibC庫syscall.h.in中新增系統(tǒng)調用號 如下所示,其中__NR_new_syscall_sample為新增系統(tǒng)調用號:
.../* 當前現(xiàn)有的系統(tǒng)調用清單 *//* OHOS customized syscalls, not compatible with ARM EABI */#define __NR_OHOS_BEGIN 500#define __NR_pthread_set_detach (__NR_OHOS_BEGIN + 0)#define __NR_pthread_join (__NR_OHOS_BEGIN + 1)#define __NR_pthread_deatch (__NR_OHOS_BEGIN + 2)#define __NR_create_user_thread (__NR_OHOS_BEGIN + 3)#define __NR_processcreate (__NR_OHOS_BEGIN + 4)#define __NR_processtart (__NR_OHOS_BEGIN + 5)#define __NR_printf (__NR_OHOS_BEGIN + 6)#define __NR_dumpmemory (__NR_OHOS_BEGIN + 13)#define __NR_mkfifo (__NR_OHOS_BEGIN + 14)#define __NR_mqclose (__NR_OHOS_BEGIN + 15)#define __NR_realpath (__NR_OHOS_BEGIN + 16)#define __NR_format (__NR_OHOS_BEGIN + 17)#define __NR_shellexec (__NR_OHOS_BEGIN + 18)#define __NR_ohoscapget (__NR_OHOS_BEGIN + 19)#define __NR_ohoscapset (__NR_OHOS_BEGIN + 20)#define __NR_new_syscall_sample (__NR_OHOS_BEGIN + 21) /* 新增的系統(tǒng)調用號 __NR_new_syscall_sample:521 */#define __NR_syscallend (__NR_OHOS_BEGIN + 22)...
- 在LibC庫中新增用戶態(tài)接口的聲明與實現(xiàn)
#include "stdio_impl.h"#include "syscall.h".../* 新增系統(tǒng)調用用戶態(tài)的接口實現(xiàn) */void newSyscallSample(int num){printf("user mode: num = %d\n", num);__syscall(SYS_new_syscall_sample, num);return;}
- 在內核系統(tǒng)調用頭文件中新增系統(tǒng)調用號 如下所示,在third_party/musl/porting/liteos_a/kernel/include/bits/syscall.h文件中,__NR_new_syscall_sample為新增系統(tǒng)調用號。
.../* 當前現(xiàn)有的系統(tǒng)調用清單 *//* OHOS customized syscalls, not compatible with ARM EABI */#define __NR_OHOS_BEGIN 500#define __NR_pthread_set_detach (__NR_OHOS_BEGIN + 0)#define __NR_pthread_join (__NR_OHOS_BEGIN + 1)#define __NR_pthread_deatch (__NR_OHOS_BEGIN + 2)#define __NR_create_user_thread (__NR_OHOS_BEGIN + 3)#define __NR_processcreate (__NR_OHOS_BEGIN + 4)#define __NR_processtart (__NR_OHOS_BEGIN + 5)#define __NR_printf (__NR_OHOS_BEGIN + 6)#define __NR_dumpmemory (__NR_OHOS_BEGIN + 13)#define __NR_mkfifo (__NR_OHOS_BEGIN + 14)#define __NR_mqclose (__NR_OHOS_BEGIN + 15)#define __NR_realpath (__NR_OHOS_BEGIN + 16)#define __NR_format (__NR_OHOS_BEGIN + 17)#define __NR_shellexec (__NR_OHOS_BEGIN + 18)#define __NR_ohoscapget (__NR_OHOS_BEGIN + 19)#define __NR_ohoscapset (__NR_OHOS_BEGIN + 20)#define __NR_new_syscall_sample (__NR_OHOS_BEGIN + 21) /* 新增的系統(tǒng)調用號 __NR_new_syscall_sample:521 */#define __NR_syscallend (__NR_OHOS_BEGIN + 22)...
在kernel/liteos_a/syscall/syscall_lookup.h中,增加一行SYSCALL_HAND_DEF(__NR_new_syscall_sample, SysNewSyscallSample, void, ARG_NUM_1):
.../* 當前現(xiàn)有的系統(tǒng)調用清單 */SYSCALL_HAND_DEF(__NR_chown, SysChown, int, ARG_NUM_3)SYSCALL_HAND_DEF(__NR_chown32, SysChown, int, ARG_NUM_3)#ifdef LOSCFG_SECURITY_CAPABILITYSYSCALL_HAND_DEF(__NR_ohoscapget, SysCapGet, UINT32, ARG_NUM_2)SYSCALL_HAND_DEF(__NR_ohoscapset, SysCapSet, UINT32, ARG_NUM_1)#endif/* 新增系統(tǒng)調用 */SYSCALL_HAND_DEF(__NR_new_syscall_sample, SysNewSyscallSample, void, ARG_NUM_1)...
- 在內核中新增內核該系統(tǒng)調用對應的處理函數(shù) 如下所示,在kernel/liteos_a/syscall/los_syscall.h中,SysNewSyscallSample為新增系統(tǒng)調用的內核處理函數(shù)聲明:
.../* 當前現(xiàn)有的系統(tǒng)調用內核處理函數(shù)聲明清單 */extern int SysClockSettime64(clockid_t clockID, const struct timespec64 *tp);extern int SysClockGettime64(clockid_t clockID, struct timespec64 *tp);extern int SysClockGetres64(clockid_t clockID, struct timespec64 *tp);extern int SysClockNanoSleep64(clockid_t clk, int flags, const struct timespec64 *req, struct timespec64 *rem);extern int SysTimerGettime64(timer_t timerID, struct itimerspec64 *value);extern int SysTimerSettime64(timer_t timerID, int flags, const struct itimerspec64 *value, struct itimerspec64 *oldValue);/* 新增的系統(tǒng)調用內核處理函數(shù)聲明 */extern void SysNewSyscallSample(int num);...
新增的系統(tǒng)調用的內核處理函數(shù)實現(xiàn)如下:
include "los_printf.h".../* 新增系統(tǒng)調用內核處理函數(shù)的實現(xiàn) */void SysNewSyscallSample(int num){PRINTK("kernel mode: num = %d\n", num);return;}
結果驗證:
用戶態(tài)程序調用newSyscallSample(10)接口,得到輸出結果如下:
/* 用戶態(tài)接口與內核態(tài)接口均有輸出,證明系統(tǒng)調用已使能 */
user mode: num = 10
kernel mode: num = 10
經常有很多小伙伴抱怨說:不知道學習鴻蒙開發(fā)哪些技術?不知道需要重點掌握哪些鴻蒙應用開發(fā)知識點?
為了能夠幫助到大家能夠有規(guī)劃的學習,這里特別整理了一套純血版鴻蒙(HarmonyOS Next)全棧開發(fā)技術的學習路線,包含了鴻蒙開發(fā)必掌握的核心知識要點,內容有(ArkTS、ArkUI開發(fā)組件、Stage模型、多端部署、分布式應用開發(fā)、WebGL、元服務、OpenHarmony多媒體技術、Napi組件、OpenHarmony內核、OpenHarmony驅動開發(fā)、系統(tǒng)定制移植等等)鴻蒙(HarmonyOS NEXT)技術知識點。
《鴻蒙 (Harmony OS)開發(fā)學習手冊》(共計892頁):https://gitcode.com/HarmonyOS_MN/733GH/overview
如何快速入門?
1.基本概念
2.構建第一個ArkTS應用
3.……
鴻蒙開發(fā)面試真題(含參考答案):https://gitcode.com/HarmonyOS_MN/733GH/overview
《OpenHarmony源碼解析》:
- 搭建開發(fā)環(huán)境
- Windows 開發(fā)環(huán)境的搭建
- Ubuntu 開發(fā)環(huán)境搭建
- Linux 與 Windows 之間的文件共享
- ……
- 系統(tǒng)架構分析
- 構建子系統(tǒng)
- 啟動流程
- 子系統(tǒng)
- 分布式任務調度子系統(tǒng)
- 分布式通信子系統(tǒng)
- 驅動子系統(tǒng)
- ……
OpenHarmony 設備開發(fā)學習手冊:https://gitcode.com/HarmonyOS_MN/733GH/overview