diff --git a/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md b/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md index faae4988fa77df6a72cbea38a208d9693eeca100..a217a33ecbbb191657402820b902ace5cd40474a 100644 --- a/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md +++ b/en/device-dev/kernel/kernel-mini-appx-lib-cmsis.md @@ -99,7 +99,7 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API

osThreadDetach

-

Detaches a thread (thread storage can be reclaimed when the thread terminates). (not implemented yet)

+

Detaches a thread (thread storage can be reclaimed when the thread terminates).

osThreadEnumerate

@@ -149,7 +149,7 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API

osThreadJoin

-

Waits for the specified thread to terminate. (not implemented yet)

+

Waits for the specified thread to terminate.

osThreadNew

@@ -186,22 +186,22 @@ The following table describes CMSIS-RTOS v2 APIs. For more details about the API

osThreadFlagsSet

-

Sets the specified thread flags for a thread. (not implemented yet)

+

Sets the specified thread flags for a thread.

osThreadFlagsClear

-

Clears the specified thread flags of the thread that is running. (not implemented yet)

+

Clears the specified thread flags of the thread that is running.

osThreadFlagsGet

-

Obtains the current thread flags of the thread that is running. (not implemented yet)

+

Obtains the current thread flags of the thread that is running.

osThreadFlagsWait

-

Waits for one or more thread flags of the currently running thread to emit a signal. (not implemented yet)

+

Waits for one or more thread flags of the currently running thread to emit a signal.

Event flag

diff --git a/en/device-dev/kernel/kernel-mini-appx-lib-posix.md b/en/device-dev/kernel/kernel-mini-appx-lib-posix.md index ad017c0f5c106c4a94b30e2f1d8653cd35b40e39..f2bb59fb86d5f262fb82e7c468029f00e695ffb9 100644 --- a/en/device-dev/kernel/kernel-mini-appx-lib-posix.md +++ b/en/device-dev/kernel/kernel-mini-appx-lib-posix.md @@ -28,7 +28,7 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs -

process

+

process

#include <stdlib.h>

@@ -65,6 +65,34 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Waits for the condition.

+

#include <pthread.h>

+ +

int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *shared);

+ +

Gets condition variable properties, currently only PTHREAD_PROCESS_PRIVATE condition variable properties are supported.

+ + +

#include <pthread.h>

+ +

int pthread_condattr_setpshared(pthread_condattr_t *attr, int shared);

+ +

Set the condition variable properties.

+ + +

#include <pthread.h>

+ +

int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock);

+ +

Get thread clock.

+ + +

#include <pthread.h>

+ +

int pthread_condattr_destroy(pthread_condattr_t *attr);

+ +

Destroy the condition variable attribute.

+ +

#include <pthread.h>

int pthread_condattr_init(pthread_condattr_t *attr);

@@ -116,6 +144,62 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

#include <pthread.h>

+

int pthread_setschedprio(pthread_t thread, int prio);

+ +

Set the thread priority.

+ + +

#include <pthread.h>

+ +

int pthread_once(pthread_once_t *onceControl, void (*initRoutine)(void));

+ +

One-off operation task.

+ + +

#include <pthread.h>

+ +

int pthread_setcancelstate(int state, int *oldState);

+ +

Switch of the thread Cancel function.

+ + +

#include <pthread.h>

+ +

int pthread_setcanceltype(int type, int *oldType);

+ +

Set the thread cancel type.

+ + +

#include <pthread.h>

+ +

int pthread_cancel(pthread_t thread);

+ +

To cancel a thread, you can only set the PTHREAD_CANCEL_ASYNCHRONOUS state and then call pthread_cancel to cancel the thread.

+ + +

#include <pthread.h>

+ +

void pthread_testcancel(void);

+ +

Cancel a thread.

+ + +

#include <pthread.h>

+ +

int pthread_equal(pthread_t thread1, pthread_t thread2);

+ +

Check whether it is the same thread.

+ + +

#include <pthread.h>

+ +

int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *outType);

+ +

Gets the mutex type attribute.

+ + +

#include <pthread.h>

+

int pthread_mutex_init(pthread_mutex_t *__restrict m, const pthread_mutexattr_t *__restrict a);

Initializes a mutex.

@@ -128,6 +212,13 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Locks a mutex.

+

#include <pthread.h>

+ +

int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTimeout);

+ +

Attempts to lock a mutex(at the given time).

+ +

#include <pthread.h>

int pthread_mutex_trylock(pthread_mutex_t *m);

@@ -170,6 +261,20 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Sets the stack size for a thread attribute object.

+

#include <pthread.h>

+ +

int pthread_attr_setstack(pthread_attr_t *attr, void *stackAddr, size_t stackSize);

+ +

Set the stack properties of the thread properties object. (not implemented yet)

+ + +

#include <pthread.h>

+ +

int pthread_attr_getstack(const pthread_attr_t *attr, void **stackAddr, size_t *stackSize);

+ +

Get stack of thread property objects. (not implemented yet)

+ +

#include <pthread.h>

int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param);

@@ -341,7 +446,7 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Obtains the file system information of a file in the specified path.

-

time

+

time

#include <sys/time.h>

@@ -399,6 +504,13 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Obtains the thread time.

+

#include <sys/times.h>

+ +

int timer_getoverrun(timer_t timerID);

+ +

Gets the softtimer timeout count.

+ +

#include <unistd.h>

int usleep(useconds_t usec);

@@ -1011,7 +1123,7 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Releases the memory space to which the PTR pointer points.

-

IPC

+

IPC

#include <semaphore.h>

@@ -1027,6 +1139,13 @@ The OpenHarmony kernel uses the **musl libc** library and self-developed APIs

Destroys a specified anonymous semaphore.

+

#include <semaphore.h>

+ +

int sem_trywait(sem_t *sem);

+ +

try to request a semaphore.

+ +

#include <semaphore.h>

int sem_init(sem_t *sem, int pshared, unsigned int value);

diff --git a/zh-cn/device-dev/faqs/faqs-kernel.md b/zh-cn/device-dev/faqs/faqs-kernel.md index 42b541cfc09099810af74957dc92f4acbe35a6db..28c3fe078d00ef632a8d5463f793eb6907f73a92 100644 --- a/zh-cn/device-dev/faqs/faqs-kernel.md +++ b/zh-cn/device-dev/faqs/faqs-kernel.md @@ -52,7 +52,7 @@ Hi3516开源板使用FAT文件系统,不允许该操作。 ### LiteOS内核已支持哪几款芯片架构 -LiteOS-M已支持risc-v、Cortex-m3\\m4\\m7\\m33、arm9,待支持c-sky、xtensa;LiteOS-A已支持armv7-a,待支持armv8-a,请关注开源社区更新。 +LiteOS-M已支持risc-v、Cortex-m3\\m4\\m7\\m33、arm9、c-sky、xtensa;LiteOS-A已支持armv7-a,待支持armv8-a,请关注开源社区更新。 ## 三方组件 diff --git a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md index 1d3ff6c62f5b278e59c9f1e068e916235d5ccdb5..cf7b39270ac939ceecf532f7fc66a98c47a36d34 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md +++ b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-cmsis.md @@ -23,85 +23,85 @@ CMSIS-RTOS v2提供下面几种功能,接口详细信息可以查看API参考 | 功能分类 | 接口名 | 描述 | | -------- | -------- | -------- | | 内核信息与控制 | osKernelGetInfo | 获取RTOS内核信息。 | -| osKernelGetState | 获取当前的RTOS内核状态。 | -| osKernelGetSysTimerCount | 获取RTOS内核系统计时器计数。 | -| osKernelGetSysTimerFreq | 获取RTOS内核系统计时器频率。 | -| osKernelInitialize | 初始化RTOS内核。 | -| osKernelLock | 锁定RTOS内核调度程序。 | -| osKernelUnlock | 解锁RTOS内核调度程序。 | -| osKernelRestoreLock | 恢复RTOS内核调度程序锁定状态。 | -| osKernelResume | 恢复RTOS内核调度程序。(暂未实现) | -| osKernelStart | 启动RTOS内核调度程序。 | -| osKernelSuspend | 挂起RTOS内核调度程序。(暂未实现) | -| osKernelGetTickCount | 获取RTOS内核滴答计数。 | -| osKernelGetTickFreq | 获取RTOS内核滴答频率。 | -| 线程管理 | osThreadDetach | 分离线程(线程终止时可以回收线程存储)。(暂未实现) | -| osThreadEnumerate | 枚举活动线程。(暂未实现) | -| osThreadExit | 终止当前正在运行的线程的执行。 | -| osThreadGetCount | 获取活动线程的数量。 | -| osThreadGetId | 返回当前正在运行的线程的线程ID。 | -| osThreadGetName | 获取线程的名称。 | -| osThreadGetPriority | 获取线程的当前优先级。 | -| osThreadGetStackSize | 获取线程的堆栈大小。 | -| osThreadGetStackSpace | 根据执行期间的堆栈水印记录获取线程的可用堆栈空间。 | -| osThreadGetState | 获取线程的当前线程状态。 | -| osThreadJoin | 等待指定线程终止。(暂未实现) | -| osThreadNew | 创建一个线程并将其添加到活动线程中。 | -| osThreadResume | 恢复线程的执行。 | -| osThreadSetPriority | 更改线程的优先级。 | -| osThreadSuspend | 暂停执行线程。 | -| osThreadTerminate | 终止线程的执行。 | -| osThreadYield | 将控制权传递给处于就绪状态的下一个线程。 | -| 线程标志 | osThreadFlagsSet | 设置线程的指定线程标志。(暂未实现) | -| osThreadFlagsClear | 清除当前正在运行的线程的指定线程标志。(暂未实现) | -| osThreadFlagsGet | 获取当前正在运行的线程的当前线程标志。(暂未实现) | -| osThreadFlagsWait | 等待当前正在运行的线程的一个或多个线程标志发出信号。(暂未实现) | +| | osKernelGetState | 获取当前的RTOS内核状态。 | +| | osKernelGetSysTimerCount | 获取RTOS内核系统计时器计数。 | +| | osKernelGetSysTimerFreq | 获取RTOS内核系统计时器频率。 | +| | osKernelInitialize | 初始化RTOS内核。 | +| | osKernelLock | 锁定RTOS内核调度程序。 | +| | osKernelUnlock | 解锁RTOS内核调度程序。 | +| | osKernelRestoreLock | 恢复RTOS内核调度程序锁定状态。 | +| | osKernelResume | 恢复RTOS内核调度程序。(暂未实现) | +| | osKernelStart | 启动RTOS内核调度程序。 | +| | osKernelSuspend | 挂起RTOS内核调度程序。(暂未实现) | +| | osKernelGetTickCount | 获取RTOS内核滴答计数。 | +| | osKernelGetTickFreq | 获取RTOS内核滴答频率。 | +| 线程管理 | osThreadDetach | 分离线程(线程终止时可以回收线程存储)。 | +| | osThreadEnumerate | 枚举活动线程。(暂未实现) | +| | osThreadExit | 终止当前正在运行的线程的执行。 | +| | osThreadGetCount | 获取活动线程的数量。 | +| | osThreadGetId | 返回当前正在运行的线程的线程ID。 | +| | osThreadGetName | 获取线程的名称。 | +| | osThreadGetPriority | 获取线程的当前优先级。 | +| | osThreadGetStackSize | 获取线程的堆栈大小。 | +| | osThreadGetStackSpace | 根据执行期间的堆栈水印记录获取线程的可用堆栈空间。 | +| | osThreadGetState | 获取线程的当前线程状态。 | +| | osThreadJoin | 等待指定线程终止。 | +| | osThreadNew | 创建一个线程并将其添加到活动线程中。 | +| | osThreadResume | 恢复线程的执行。 | +| | osThreadSetPriority | 更改线程的优先级。 | +| | osThreadSuspend | 暂停执行线程。 | +| | osThreadTerminate | 终止线程的执行。 | +| | osThreadYield | 将控制权传递给处于就绪状态的下一个线程。 | +| 线程标志 | osThreadFlagsSet | 设置线程的指定线程标志。 | +| | osThreadFlagsClear | 清除当前正在运行的线程的指定线程标志。 | +| | osThreadFlagsGet | 获取当前正在运行的线程的当前线程标志。 | +| | osThreadFlagsWait | 等待当前正在运行的线程的一个或多个线程标志发出信号。 | | 事件标志 | osEventFlagsGetName | 获取事件标志对象的名称。(暂未实现) | -| osEventFlagsNew | 创建并初始化事件标志对象。 | -| osEventFlagsDelete | 删除事件标志对象。 | -| osEventFlagsSet | 设置指定的事件标志。 | -| osEventFlagsClear | 清除指定的事件标志。 | -| osEventFlagsGet | 获取当前事件标志。 | -| osEventFlagsWait | 等待一个或多个事件标志被发出信号。 | +| | osEventFlagsNew | 创建并初始化事件标志对象。 | +| | osEventFlagsDelete | 删除事件标志对象。 | +| | osEventFlagsSet | 设置指定的事件标志。 | +| | osEventFlagsClear | 清除指定的事件标志。 | +| | osEventFlagsGet | 获取当前事件标志。 | +| | osEventFlagsWait | 等待一个或多个事件标志被发出信号。 | | 通用等待函数 | osDelay | 等待超时(时间延迟)。 | -| osDelayUntil | 等到指定时间。 | +| | osDelayUntil | 等到指定时间。 | | 计时器管理 | osTimerDelete | 删除计时器。 | -| osTimerGetName | 获取计时器的名称。(暂未实现) | -| osTimerIsRunning | 检查计时器是否正在运行。 | -| osTimerNew | 创建和初始化计时器。 | -| osTimerStart | 启动或重新启动计时器。 | -| osTimerStop | 停止计时器。 | +| | osTimerGetName | 获取计时器的名称。(暂未实现) | +| | osTimerIsRunning | 检查计时器是否正在运行。 | +| | osTimerNew | 创建和初始化计时器。 | +| | osTimerStart | 启动或重新启动计时器。 | +| | osTimerStop | 停止计时器。 | | 互斥管理 | osMutexAcquire | 获取互斥或超时(如果已锁定)。 | -| osMutexDelete | 删除互斥对象。 | -| osMutexGetName | 获取互斥对象的名称。(暂未实现) | -| osMutexGetOwner | 获取拥有互斥对象的线程。 | -| osMutexNew | 创建并初始化Mutex对象。 | -| osMutexRelease | 释放由osMutexAcquire获取的Mutex。 | +| | osMutexDelete | 删除互斥对象。 | +| | osMutexGetName | 获取互斥对象的名称。(暂未实现) | +| | osMutexGetOwner | 获取拥有互斥对象的线程。 | +| | osMutexNew | 创建并初始化Mutex对象。 | +| | osMutexRelease | 释放由osMutexAcquire获取的Mutex。 | | 信号量 | osSemaphoreAcquire | 获取信号量令牌或超时(如果没有可用的令牌)。 | -| osSemaphoreDelete | 删除一个信号量对象。 | -| osSemaphoreGetCount | 获取当前信号量令牌计数。 | -| osSemaphoreGetName | 获取信号量对象的名称。(暂未实现) | -| osSemaphoreNew | 创建并初始化一个信号量对象。 | -| osSemaphoreRelease | 释放信号量令牌,直到初始最大计数。 | +| | osSemaphoreDelete | 删除一个信号量对象。 | +| | osSemaphoreGetCount | 获取当前信号量令牌计数。 | +| | osSemaphoreGetName | 获取信号量对象的名称。(暂未实现) | +| | osSemaphoreNew | 创建并初始化一个信号量对象。 | +| | osSemaphoreRelease | 释放信号量令牌,直到初始最大计数。 | | 内存池 | osMemoryPoolAlloc | 从内存池分配一个内存块。 | -| osMemoryPoolDelete | 删除内存池对象。 | -| osMemoryPoolFree | 将分配的内存块返回到内存池。 | -| osMemoryPoolGetBlockSize | 获取内存池中的内存块大小。 | -| osMemoryPoolGetCapacity | 获取内存池中最大的内存块数。 | -| osMemoryPoolGetCount | 获取内存池中使用的内存块数。 | -| osMemoryPoolGetName | 获取内存池对象的名称。 | -| osMemoryPoolGetSpace | 获取内存池中可用的内存块数。 | -| osMemoryPoolNew | 创建并初始化一个内存池对象。 | +| | osMemoryPoolDelete | 删除内存池对象。 | +| | osMemoryPoolFree | 将分配的内存块返回到内存池。 | +| | osMemoryPoolGetBlockSize | 获取内存池中的内存块大小。 | +| | osMemoryPoolGetCapacity | 获取内存池中最大的内存块数。 | +| | osMemoryPoolGetCount | 获取内存池中使用的内存块数。 | +| | osMemoryPoolGetName | 获取内存池对象的名称。 | +| | osMemoryPoolGetSpace | 获取内存池中可用的内存块数。 | +| | osMemoryPoolNew | 创建并初始化一个内存池对象。 | | 消息队列 | osMessageQueueDelete | 删除消息队列对象。 | -| osMessageQueueGet | 从队列获取消息,或者如果队列为空,则从超时获取消息。 | -| osMessageQueueGetCapacity | 获取消息队列中的最大消息数。 | -| osMessageQueueGetCount | 获取消息队列中排队的消息数。 | -| osMessageQueueGetMsgSize | 获取内存池中的最大消息大小。 | -| osMessageQueueGetName | 获取消息队列对象的名称。(暂未实现) | -| osMessageQueueGetSpace | 获取消息队列中消息的可用插槽数。 | -| osMessageQueueNew | 创建和初始化消息队列对象。 | -| osMessageQueuePut | 如果队列已满,则将消息放入队列或超时。 | -| osMessageQueueReset | 将消息队列重置为初始空状态。(暂未实现) | +| | osMessageQueueGet | 从队列获取消息,或者如果队列为空,则从超时获取消息。 | +| | osMessageQueueGetCapacity | 获取消息队列中的最大消息数。 | +| | osMessageQueueGetCount | 获取消息队列中排队的消息数。 | +| | osMessageQueueGetMsgSize | 获取内存池中的最大消息大小。 | +| | osMessageQueueGetName | 获取消息队列对象的名称。(暂未实现) | +| | osMessageQueueGetSpace | 获取消息队列中消息的可用插槽数。 | +| | osMessageQueueNew | 创建和初始化消息队列对象。 | +| | osMessageQueuePut | 如果队列已满,则将消息放入队列或超时。 | +| | osMessageQueueReset | 将消息队列重置为初始空状态。(暂未实现) | ### 开发流程 diff --git a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md index ada544979eab74f57bd60c20393f167a199605bf..89c0c75c386fdc2c7a007a197f02d8449d7757a8 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md +++ b/zh-cn/device-dev/kernel/kernel-mini-appx-lib-posix.md @@ -18,161 +18,178 @@ OpenHarmony内核使用**musl libc**库以及自研接口,支持部分标准PO **表1** POSIX接口说明 -| 类别 | 需要包含的头文件 | 接口名 | 描述 | +| 类别 | 需要包含的头文件 | 接口名 | 描述 | | -------- | -------- | -------- | -------- | -| process | \#include <stdlib.h> | void abort(void); | 中止线程执行 | -| \#include <assert.h> | void assert(scalar expression); | 断言为假终止线程 | -| \#include <pthread.h> | int pthread_cond_destroy(pthread_cond_t \*cond); | 销毁条件变量 | -| \#include <pthread.h> | int pthread_cond_init(pthread_cond_t \*restrict cond, const pthread_condattr_t \*restrict attr); | 初始化条件变量 | -| \#include <pthread.h> | int pthread_cond_timedwait(pthread_cond_t \*restrict cond, pthread_mutex_t \*restrict mutex, const struct timespec \*restrict abstime); | 等待条件 | -| \#include <pthread.h> | int pthread_condattr_init(pthread_condattr_t \*attr); | 初始化条件变量属性对象 | -| \#include <pthread.h> | int pthread_mutex_unlock(pthread_mutex_t \*mutex); | 解锁互斥锁 | -| \#include <pthread.h> | int pthread_create(pthread_t \*thread, const pthread_attr_t \*attr, void \*(\*start_routine)(void \*), void \*arg); | 创建一个新的线程 | -| \#include <pthread.h> | int pthread_join(pthread_t thread, void \*\*retval); | 等待指定的线程结束 | -| \#include <pthread.h> | pthread_t pthread_self(void); | 获取当前线程的ID | -| \#include <pthread.h> | int pthread_getschedparam(pthread_t thread, int \*policy, struct sched_param \*param); | 获取线程的调度策略和参数 | -| \#include <pthread.h> | int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param \*param); | 设置线程的调度策略和参数 | -| \#include <pthread.h> | int pthread_mutex_init(pthread_mutex_t \*__restrict m, const pthread_mutexattr_t \*__restrict a); | 初始化互斥锁 | -| \#include <pthread.h> | int pthread_mutex_lock(pthread_mutex_t \*m); | 互斥锁加锁操作 | -| \#include <pthread.h> | int pthread_mutex_trylock(pthread_mutex_t \*m); | 互斥锁尝试加锁操作 | -| \#include <pthread.h> | int pthread_mutex_destroy(pthread_mutex_t \*m); | 销毁互斥锁 | -| \#include <pthread.h> | int pthread_attr_init(pthread_attr_t \*attr); | 初始化线程属性对象 | -| \#include <pthread.h> | int pthread_attr_destroy(pthread_attr_t \*attr); | 销毁线程属性对象 | -| \#include <pthread.h> | int pthread_attr_getstacksize(const pthread_attr_t \*attr, size_t \*stacksize); | 获取线程属性对象的堆栈大小 | -| \#include <pthread.h> | int pthread_attr_setstacksize(pthread_attr_t \*attr, size_t stacksize); | 设置线程属性对象的堆栈大小 | -| \#include <pthread.h> | int pthread_attr_getschedparam(const pthread_attr_t \*attr, struct sched_param \*param); | 获取线程属性对象的调度参数属性 | -| \#include <pthread.h> | int pthread_attr_setschedparam(pthread_attr_t \*attr, const struct sched_param \*param); | 设置线程属性对象的调度参数属性 | -| \#include <pthread.h> | int pthread_getname_np(pthread_t pthread, char \*name, size_t len); | 获取线程名称 | -| \#include <pthread.h> | int pthread_setname_np(pthread_t pthread, const char \*name); | 设置线程名称 | -| \#include <pthread.h> | int pthread_cond_broadcast(pthread_cond_t \*c); | 解除若干已被等待条件阻塞的线程 | -| \#include <pthread.h> | int pthread_cond_signal(pthread_cond_t \*c); | 解除被阻塞的线程 | -| \#include <pthread.h> | int pthread_cond_wait(pthread_cond_t \*__restrict c, pthread_mutex_t \*__restrict m); | 等待条件 | -| fs | \#include <libgen.h> | char \*dirname(char \*path); | 获取目录名 | -| \#include <dirent.h> | struct dirent \*readdir(DIR \*dirp); | 读目录 | -| \#include <sys/stat.h> | int stat(const char \*restrict path, struct stat \*restrict buf); | 获取文件信息 | -| \#include <unistd.h> | int unlink(const char \*pathname); | 删除文件 | -| \#include <fcntl.h | int open(const char \*path, int oflags, ...); | 用于打开文件,如文件不存在,创建文件并打开 | -| \#include <nistd.h> | int close(int fd); | 关闭文件 | -| \#include <stdio.h> | int rename(const char \*oldpath, const char \*newpath); | 重命名指定的文件 | -| \#include <dirent.h> | DIR  \*opendir(const char \*dirname); | 打开指定目录 | -| \#include <dirent.h> | int closedir(DIR \*dir); | 关闭指定目录 | -| \#include <sys/mount.h> | int mount(const char \*source, const char \*target, const char \*filesystemtype, unsigned long mountflags, const void \*data); | 挂载文件系统 | -| \#include <sys/mount.h> | int umount(const char \*target); | 卸载文件系统 | -| \#include <sys/mount.h> | int umount2(const char \*target, int flag); | 卸载文件系统 | -| \#include <sys/stat.h> | int fsync(int fd); | 将与指定文件描述符关联的文件同步到存储设备 | -| \#include <sys/stat.h> | int mkdir(const char \*pathname, mode_t mode); | 创建目录 | -| \#include <unistd.h> | int rmdir(const char \*path); | 删除目录 | -| \#include <sys/stat.h> | int fstat(int fd, struct stat \*buf); | 获取文件状态信息 | -| \#include <sys/statfs.h> | int statfs(const char \*path, struct statfs \*buf); | 获取指定路径下文件的文件系统信息 | -| time | \#include <sys/time.h> | int gettimeofday(struct timeval \*tv, struct timezone \*tz); | 获取时间。当前暂无时区概念,tz返回为空 | -| \#include <time.h> | struct tm \*gmtime(const time_t \*timep); | 将日期和时间转换为细分时间或ASCII | -| \#include <time.h> | struct tm \*localtime(const time_t \*timep); | 获取时间 | -| \#include <time.h> | struct tm \*localtime_r(const time_t \*timep, struct tm \*result); | 获取时间 | -| \#include <time.h> | time_t mktime(struct tm \*tm); | 将日期和时间转换为细分时间或ASCII | -| \#include <time.h> | size_t strftime(char \*s, size_t max, const char \*format,const struct tm \*tm); | 格式化日期和时间字符串 | -| \#include <time.h> | time_t time(time_t \*tloc); | 获得日历时间 | -| \#include <sys/times.h> | clock_t times(struct tms \*buf); | 获取线程时间 | -| \#include <unistd.h> | int usleep(useconds_t usec); | 休眠(微秒单位) | -| \#include <time.h> | int nanosleep(const struct timespec \*tspec1, struct timespec \*tspec2); | 暂停当前线程直到指定的时间到达 | -| \#include <time.h> | int clock_gettime(clockid_t id, struct timespec \*tspec); | 获取时钟的时间 | -| \#include <time.h> | int timer_create(clockid_t id, struct sigevent \*__restrict evp, timer_t \*__restrict t); | 为线程创建计时器 | -| \#include <time.h> | int timer_delete(timer_t t); | 为线程删除计时器 | -| \#include <time.h> | int timer_settime(timer_t t, int flags, const struct itimerspec \*__restrict val, struct itimerspec \*__restrict old); | 为线程设置计时器 | -| \#include <time.h> | time_t time (time_t \*t); | 获取时间 | -| \#include <time.h> | char \*strptime(const char \*s, const char \*format, struct tm \*tm); | 将时间的字符串表示形式转换为时间tm结构 | -| util | \#include <stdlib.h> | int atoi(const char \*nptr); | 字符串转换整型(int) | -| \#include <stdlib.h> | long atol(const char \*nptr); | 字符串转换整型(long) | -| \#include <stdlib.h> | long long atoll(const char \*nptr); | 字符串转换整型(long long) | -| \#include <ctype.h> | int isalnum(int c); | 检查字母数字字符 | -| \#include <ctype.h> | int isascii(int c); | 检查ASCII | -| \#include <ctype.h> | int isdigit(int c); | 检查数字字符 | -| \#include <ctype.h> | int islower(int c); | 检查小写字符 | -| \#include <ctype.h> | int isprint(int c); | 检查任何可打印字符,包括空格 | -| \#include <ctype.h> | int isspace(int c); | 检查空格字符 | -| \#include <ctype.h> | int isupper(int c); | 检查所传的字符是否是大写字母 | -| \#include <ctype.h> | int isxdigit(int c); | 判断字符是否为十六进制数 | -| \#include <stdlib.h> | long int random (void); | 生成伪随机数 | -| \#include <stdlib.h> | void srandom(unsigned int seed); | 初始化随机数生成器 | -| \#include <ctype.h> | int tolower(int c); | 字母转换成小写 | -| \#include <ctype.h> | int toupper(int c); | 字母转换成大写 | -| \#include <stdarg.h> | type va_arg(va_list ap, type); | 获取可变参数的当前参数,返回指定类型并将指针指向下一参数 | -| \#include <stdarg.h> | void va_copy(va_list dest, va_list src); | 复制参数 | -| \#include <stdarg.h> | void va_end(va_list ap); | 清空va_list可变参数列表 | -| \#include <stdarg.h> | void va_start(va_list ap, last); | 定义变长参数列表的起始位置 | -| \#include <string.h> | char \*strchr(const char \*s, int c); | 在字符串中定位字符 | -| \#include <string.h> | int strcmp(const char \*s1, const char \*s2); | 比较字符串 | -| \#include <string.h> | size_t strcspn(const char \*s, const char \*reject); | 获取前缀子串的长度 | -| \#include <string.h> | char \*strdup(const char \*s); | 字符串拷贝到新建的位置处 | -| \#include <string.h> | size_t strlen(const char \*s); | 计算字符串长度 | -| \#include <strings.h> | int strncasecmp(const char \*s1, const char \*s2, size_t n); | 比较固定长度字符串(忽略大小写) | -| \#include <strings.h> | int strcasecmp(const char \*s1, const char \*s2); | 比较字符串(忽略大小写) | -| \#include <string.h> | int strncmp(const char \*s1, const char \*s2, size_t n); | 比较字符串(指定长度) | -| \#include <string.h> | char \*strrchr(const char \*s, int c); | 在字符串中定位字符 | -| \#include <string.h> | char \*strstr(const char \*haystack, const char \*needle); | 寻找指定的子串 | -| \#include <stdlib.h> | long int strtol(const char \*nptr, char \*\*endptr, int base); | 将字符串转换为long型整数 | -| \#include <stdlib.h> | unsigned long int strtoul(const char \*nptr, char \*\*endptr, int base); | 将字符串转换为unsigned long型整数 | -| \#include <stdlib.h> | unsigned long long int strtoull(const char \*nptr, char \*\*endptr,int base); | 将字符串转换为unsigned long long型整数 | -| \#include <regex.h> | int regcomp(regex_t \*preg, const char \*regex, int cflags); | 编译正则表达式 | -| \#include <regex.h> | int regexec(const regex_t \*preg, const char \*string, size_t nmatch,regmatch_t pmatch[], int eflags); | 匹配正则表达式 | -| \#include <regex.h> | void regfree(regex_t \*preg); | 释放正则表达式 | -| \#include <string.h> | char \*strerror(int errnum); | 返回描述错误号的字符串 | -| math | \#include <stdlib.h> | int abs(int i); | 取绝对值 | -| \#include <math.h> | double log(double x); | 自然对数函数 | -| \#include <math.h> | double pow(double x, double y); | 求x的指数y次幂 | -| \#include <math.h> | double round(double x); | 从零开始,舍入到最接近的整数 | -| \#include <math.h> | double sqrt(double x); | 平方根 | -| IO | \#include <stdio.h> | void clearerr(FILE \*stream); | 清除流的文件结尾和错误指示 | -| \#include <stdio.h> | int fclose(FILE \*stream); | 关闭文件流 | -| \#include <stdio.h> | FILE \*fdopen(int fd, const char \*mode); | 通过文件描述符打开文件流 | -| \#include <stdio.h> | int feof(FILE \*stream); | 检测返回文件末尾指示位 | -| \#include <stdio.h> | int fflush(FILE \*stream); | 刷新流 | -| \#include <stdio.h> | char \*fgets(char \*s, int size, FILE \*stream); | 读取流的下一行 | -| \#include <stdio.h> | int fileno(FILE \*stream); | 返回流的文件描述符 | -| \#include <stdio.h> | FILE \*fopen(const char \*path, const char \*mode); | 打开流 | -| \#include <stdio.h> | int fputs(const char \*s, FILE \*stream); | 向指定流写入一行 | -| \#include <stdio.h> | size_t fread(void \*ptr, size_t size, size_t nmemb, FILE \*stream); | 读一个流 | -| \#include <stdio.h> | int fseek(FILE \*stream, long offset, int whence); | 设置流指针的位置 | -| \#include <stdio.h> | long ftell(FILE \*stream); | 获取流指针的位置 | -| \#include <stdio.h> | size_t fwrite(const void \*ptr, size_t size, size_t nmemb,FILE \*stream); | 向流写入 | -| \#include <stdio.h> | void perror(const char \*s); | 打印系统错误信息 | -| \#include <stdio.h> | void rewind(FILE \*stream); | 重新定位流 | -| \#include <unistd.h> | ssize_t write(int fd, const void \*buf, size_t size); | 写文件内容 | -| \#include <unistd.h> | ssize_t read(int fd, void \*buf, size_t size); | 读文件内容 | -| net | \#include <sys/socket.h> | void freeaddrinfo(struct addrinfo \*res); | 释放调用getaddrinfo所分配的动态内存 | -| \#include <sys/socket.h> | int getaddrinfo(const char \*restrict nodename,const char \*restrict servname,const struct addrinfo \*restrict hints,struct addrinfo \*\*restrict res); | 网络地址和服务转换 | -| \#include <sys/socket.h> | int getnameinfo(const struct sockaddr \*restrict sa, socklen_t salen,char \*restrict node, socklen_t nodelen, char \*restrict service,socklen_t servicelen, int flags); | 以协议无关的方式进行地址到名称的转换 | -| \#include <net/if.h> | unsigned int if_nametoindex(const char \*ifname); | 通过网络接口名得到索引 | -| \#include <arpa/inet.h> | in_addr_t inet_addr(const char \*cp); | 网络主机地址点分十进制形式转换位二进制形式 | -| \#include <arpa/inet.h> | char \*inet_ntoa(struct in_addr in); | 网络主机地址二进制形式转换位点分十进制形式 | -| \#include <arpa/inet.h> | const char \*inet_ntop(int af, const void \*src,char \*dst, socklen_t size); | 网络地址转换 | -| \#include <arpa/inet.h> | int inet_pton(int af, const char \*src, void \*dst); | 网络地址转换 | -| \#include <sys/socket.h> | int listen(int sockfd, int backlog); | 监听套接字 | -| \#include <sys/socket.h> | ssize_t recvmsg(int sockfd, struct msghdr \*msg, int flags); | 从套接字接收消息.只支持iov大小为1的场景,且不支持ancillary消息 | -| \#include <sys/socket.h> | ssize_t send(int sockfd, const void \*buf, size_t len, int flags); | 从socket发送消息 | -| \#include <sys/socket.h> | ssize_t sendmsg(int sockfd, const struct msghdr \*msg, int flags); | 从socket发送消息。不支持ancillary消息 | -| \#include <sys/socket.h> | ssize_t sendto(int sockfd, const void \*buf, size_t len, int flags,const struct sockaddr \*dest_addr, socklen_t addrlen); | 从socket发送消息 | -| \#include <sys/socket.h> | int setsockopt(int sockfd, int level, int optname,const void \*optval, socklen_t optlen); | 设置与套接字关联的选项 | -| mem | \#include <string.h> | int memcmp(const void \*s1, const void \*s2, size_t n); | 内存比较 | -| \#include <string.h> | void \*memcpy(void \*dest, const void \*src, size_t n); | 内存拷贝 | -| \#include <string.h> | void \*memset(void \*s, int c, size_t n); | 内存初始化 | -| \#include <stdlib.h> | void \*realloc(void \*ptr, size_t size); | 重分配内存 | -| \#include <stdlib.h> | void \*malloc(size_t size); | 动态分配内存块大小 | -| \#include <stdlib.h> | void free(void \*ptr); | 释放ptr所指向的内存空间 | -| IPC | \#include <semaphore.h> | int sem_timedwait(sem_t \*sem, const struct timespec \*abs_timeout); | 计时锁定信号量 | -| \#include <semaphore.h> | int sem_destroy(sem_t \*sem); | 销毁指定的无名信号量 | -| \#include <semaphore.h> | int sem_init(sem_t \*sem, int pshared, unsigned int value); | 创建并初始化一个无名信号量 | -| \#include <semaphore.h> | int sem_post(sem_t \*sem); | 增加信号量计数 | -| \#include <semaphore.h> | int sem_wait(sem_t \*sem); | 获取信号量 | -| \#include <mqueue.h> | mqd_t mq_open(const char \*mqName, int openFlag, ...); | 此API用于打开一个具有指定名称的已有消息队列或创建一个新的消息队列 | -| \#include <mqueue.h> | int mq_close(mqd_t personal); | 此API用于关闭具有指定描述符的消息队列 | -| \#include <mqueue.h> | int mq_unlink(const char \*mqName); | 此API用于删除具有指定名称的消息队列 | -| \#include <mqueue.h> | int mq_send(mqd_t personal, const char \*msg, size_t msgLen, unsigned int msgPrio); | 此API用于将具有指定内容和长度的消息放入具有指定描述符的消息队列中 | -| \#include <mqueue.h> | ssize_t mq_receive(mqd_t personal, char \*msg, size_t msgLen, unsigned int \*msgPrio); | 此API用于从具有指定描述符的消息队列中删除最老的消息,并将其放入msg_ptr所指向的缓冲区中 | -| \#include <mqueue.h> | int mq_timedsend(mqd_t personal, const char \*msg, size_t msgLen, unsigned int msgPrio, const struct timespec \*absTimeout) | 此API用于在预定时间将具有指定内容和长度的消息放入具有描述符的消息队列中 | -| \#include <mqueue.h> | ssize_t mq_timedreceive(mqd_t personal, char \*msg, size_t msgLen, unsigned int \*msgPrio, const struct timespec \*absTimeout); | 此API用于从具有指定描述符的消息队列消息中获取具有指定消息内容和长度的消息 | -| \#include <mqueue.h> | int mq_setattr(mqd_t mqdes, const struct mq_attr \*__restrict newattr, struct mq_attr \*__restrict oldattr); | 设置描述符指定的消息队列属性 | -| version | \#include <libc.h> | const char \*libc_get_version_string(void); | 获取libc版本字符串 | -| \#include <libc.h> | int libc_get_version(void); | 获取libc版本号 | +| process | \#include <stdlib.h> | void abort(void); | 中止线程执行 | +| | \#include <assert.h> | void assert(scalar expression); | 断言为假终止线程 | +| | \#include <pthread.h> | int pthread_cond_destroy(pthread_cond_t \*cond); | 销毁条件变量 | +| | \#include <pthread.h> | int pthread_cond_init(pthread_cond_t \*restrict cond, const pthread_condattr_t \*restrict attr); | 初始化条件变量 | +| | \#include | int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *shared); | 获取条件变量属性,目前只支持获取PTHREAD_PROCESS_PRIVATE条件变量属性 | +| | \#include <pthread.h> | int pthread_condattr_setpshared(pthread_condattr_t *attr, int shared); | 设置条件变量属性 | +| | \#include <pthread.h> | int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock); | 获取线程时钟 | +| | \#include <pthread.h> | int pthread_condattr_destroy(pthread_condattr_t *attr); | 删除存储并使属性对象无效 | +| | \#include <pthread.h> | int pthread_cond_timedwait(pthread_cond_t \*restrict cond, pthread_mutex_t \*restrict mutex, const struct timespec \*restrict abstime); | 等待条件 | +| | \#include <pthread.h> | int pthread_condattr_init(pthread_condattr_t \*attr); | 初始化条件变量属性对象 | +| | \#include <pthread.h> | int pthread_mutex_unlock(pthread_mutex_t \*mutex); | 解锁互斥锁 | +| | \#include <pthread.h> | int pthread_create(pthread_t \*thread, const pthread_attr_t \*attr, void \*(\*start_routine)(void \*), void \*arg); | 创建一个新的线程 | +| | \#include <pthread.h> | int pthread_join(pthread_t thread, void \*\*retval); | 等待指定的线程结束 | +| | \#include <pthread.h> | pthread_t pthread_self(void); | 获取当前线程的ID | +| | \#include <pthread.h> | int pthread_getschedparam(pthread_t thread, int \*policy, struct sched_param \*param); | 获取线程的调度策略和参数 | +| | \#include <pthread.h> | int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param \*param); | 设置线程的调度策略和参数 | +| | #include | int pthread_setschedprio(pthread_t thread, int prio); | 设置线程优先级 | +| | #include | int pthread_once(pthread_once_t *onceControl, void (*initRoutine)(void)); | 一次性操作任务 | +| | #include | int pthread_setcancelstate(int state, int *oldState); | 线程cancel功能开关 | +| | #include | int pthread_setcanceltype(int type, int *oldType); | 设置线程cancel类型 | +| | #include | int pthread_cancel(pthread_t thread); | 取消线程,目前仅支持先设置PTHREAD_CANCEL_ASYNCHRONOUS状态,再调用pthread_cancel取消线程 | +| | #include | void pthread_testcancel(void); | cancel线程 | +| | #include | int pthread_equal(pthread_t thread1, pthread_t thread2); | 判断是否为同一线程 | +| | #include | int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *outType); | 获取互斥锁的类型属性 | +| | \#include <pthread.h> | int pthread_mutex_init(pthread_mutex_t \*__restrict m, const pthread_mutexattr_t \*__restrict a); | 初始化互斥锁 | +| | \#include <pthread.h> | int pthread_mutex_lock(pthread_mutex_t \*m); | 互斥锁加锁操作 | +| | \#include | int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTimeout); | 申请互斥锁(只在设定时间内阻塞) | +| | \#include <pthread.h> | int pthread_mutex_trylock(pthread_mutex_t \*m); | 互斥锁尝试加锁操作 | +| | \#include <pthread.h> | int pthread_mutex_destroy(pthread_mutex_t \*m); | 销毁互斥锁 | +| | \#include <pthread.h> | int pthread_attr_init(pthread_attr_t \*attr); | 初始化线程属性对象 | +| | \#include <pthread.h> | int pthread_attr_destroy(pthread_attr_t \*attr); | 销毁线程属性对象 | +| | \#include <pthread.h> | int pthread_attr_getstacksize(const pthread_attr_t \*attr, size_t \*stacksize); | 获取线程属性对象的堆栈大小 | +| | \#include <pthread.h> | int pthread_attr_setstacksize(pthread_attr_t \*attr, size_t stacksize); | 设置线程属性对象的堆栈大小 | +| | \#include | int pthread_attr_setstack(pthread_attr_t *attr, void *stackAddr, size_t stackSize); | 设置线程属性对象的堆栈属性(暂未实现) | +| | \#include | int pthread_attr_getstack(const pthread_attr_t *attr, void **stackAddr, size_t *stackSize); | 获取线程属性对象的堆栈(暂未实现) | +| | \#include <pthread.h> | int pthread_attr_getschedparam(const pthread_attr_t \*attr, struct sched_param \*param); | 获取线程属性对象的调度参数属性 | +| | \#include <pthread.h> | int pthread_attr_setschedparam(pthread_attr_t \*attr, const struct sched_param \*param); | 设置线程属性对象的调度参数属性 | +| | \#include <pthread.h> | int pthread_getname_np(pthread_t pthread, char \*name, size_t len); | 获取线程名称 | +| | \#include <pthread.h> | int pthread_setname_np(pthread_t pthread, const char \*name); | 设置线程名称 | +| | \#include <pthread.h> | int pthread_cond_broadcast(pthread_cond_t \*c); | 解除若干已被等待条件阻塞的线程 | +| | \#include <pthread.h> | int pthread_cond_signal(pthread_cond_t \*c); | 解除被阻塞的线程 | +| | \#include <pthread.h> | int pthread_cond_wait(pthread_cond_t \*__restrict c, pthread_mutex_t \*__restrict m); | 等待条件 | +| fs | \#include <libgen.h> | char \*dirname(char \*path); | 获取目录名 | +| | \#include <dirent.h> | struct dirent \*readdir(DIR \*dirp); | 读目录 | +| | \#include <sys/stat.h> | int stat(const char \*restrict path, struct stat \*restrict buf); | 获取文件信息 | +| | \#include <unistd.h> | int unlink(const char \*pathname); | 删除文件 | +| | \#include <fcntl.h | int open(const char \*path, int oflags, ...); | 用于打开文件,如文件不存在,创建文件并打开 | +| | \#include <nistd.h> | int close(int fd); | 关闭文件 | +| | \#include <stdio.h> | int rename(const char \*oldpath, const char \*newpath); | 重命名指定的文件 | +| | \#include <dirent.h> | DIR  \*opendir(const char \*dirname); | 打开指定目录 | +| | \#include <dirent.h> | int closedir(DIR \*dir); | 关闭指定目录 | +| | \#include <sys/mount.h> | int mount(const char \*source, const char \*target, const char \*filesystemtype, unsigned long mountflags, const void \*data); | 挂载文件系统 | +| | \#include <sys/mount.h> | int umount(const char \*target); | 卸载文件系统 | +| | \#include <sys/mount.h> | int umount2(const char \*target, int flag); | 卸载文件系统 | +| | \#include <sys/stat.h> | int fsync(int fd); | 将与指定文件描述符关联的文件同步到存储设备 | +| | \#include <sys/stat.h> | int mkdir(const char \*pathname, mode_t mode); | 创建目录 | +| | \#include <unistd.h> | int rmdir(const char \*path); | 删除目录 | +| | \#include <sys/stat.h> | int fstat(int fd, struct stat \*buf); | 获取文件状态信息 | +| | \#include <sys/statfs.h> | int statfs(const char \*path, struct statfs \*buf); | 获取指定路径下文件的文件系统信息 | +| time | \#include <sys/time.h> | int gettimeofday(struct timeval \*tv, struct timezone \*tz); | 获取时间。当前暂无时区概念,tz返回为空 | +| | \#include <time.h> | struct tm \*gmtime(const time_t \*timep); | 将日期和时间转换为细分时间或ASCII | +| | \#include <time.h> | struct tm \*localtime(const time_t \*timep); | 获取时间 | +| | \#include <time.h> | struct tm \*localtime_r(const time_t \*timep, struct tm \*result); | 获取时间 | +| | \#include <time.h> | time_t mktime(struct tm \*tm); | 将日期和时间转换为细分时间或ASCII | +| | \#include <time.h> | size_t strftime(char \*s, size_t max, const char \*format,const struct tm \*tm); | 格式化日期和时间字符串 | +| | \#include <time.h> | time_t time(time_t \*tloc); | 获得日历时间 | +| | \#include <sys/times.h> | clock_t times(struct tms \*buf); | 获取线程时间 | +| | \#include | int timer_getoverrun(timer_t timerID); | 获取定时器超时次数 | +| | \#include <unistd.h> | int usleep(useconds_t usec); | 休眠(微秒单位) | +| | \#include <time.h> | int nanosleep(const struct timespec \*tspec1, struct timespec \*tspec2); | 暂停当前线程直到指定的时间到达 | +| | \#include <time.h> | int clock_gettime(clockid_t id, struct timespec \*tspec); | 获取时钟的时间 | +| | \#include <time.h> | int timer_create(clockid_t id, struct sigevent \*__restrict evp, timer_t \*__restrict t); | 为线程创建计时器 | +| | \#include <time.h> | int timer_delete(timer_t t); | 为线程删除计时器 | +| | \#include <time.h> | int timer_settime(timer_t t, int flags, const struct itimerspec \*__restrict val, struct itimerspec \*__restrict old); | 为线程设置计时器 | +| | \#include <time.h> | time_t time (time_t \*t); | 获取时间 | +| | \#include <time.h> | char \*strptime(const char \*s, const char \*format, struct tm \*tm); | 将时间的字符串表示形式转换为时间tm结构 | +| util | \#include <stdlib.h> | int atoi(const char \*nptr); | 字符串转换整型(int) | +| | \#include <stdlib.h> | long atol(const char \*nptr); | 字符串转换整型(long) | +| | \#include <stdlib.h> | long long atoll(const char \*nptr); | 字符串转换整型(long long) | +| | \#include <ctype.h> | int isalnum(int c); | 检查字母数字字符 | +| | \#include <ctype.h> | int isascii(int c); | 检查ASCII | +| | \#include <ctype.h> | int isdigit(int c); | 检查数字字符 | +| | \#include <ctype.h> | int islower(int c); | 检查小写字符 | +| | \#include <ctype.h> | int isprint(int c); | 检查任何可打印字符,包括空格 | +| | \#include <ctype.h> | int isspace(int c); | 检查空格字符 | +| | \#include <ctype.h> | int isupper(int c); | 检查所传的字符是否是大写字母 | +| | \#include <ctype.h> | int isxdigit(int c); | 判断字符是否为十六进制数 | +| | \#include <stdlib.h> | long int random (void); | 生成伪随机数 | +| | \#include <stdlib.h> | void srandom(unsigned int seed); | 初始化随机数生成器 | +| | \#include <ctype.h> | int tolower(int c); | 字母转换成小写 | +| | \#include <ctype.h> | int toupper(int c); | 字母转换成大写 | +| | \#include <stdarg.h> | type va_arg(va_list ap, type); | 获取可变参数的当前参数,返回指定类型并将指针指向下一参数 | +| | \#include <stdarg.h> | void va_copy(va_list dest, va_list src); | 复制参数 | +| | \#include <stdarg.h> | void va_end(va_list ap); | 清空va_list可变参数列表 | +| | \#include <stdarg.h> | void va_start(va_list ap, last); | 定义变长参数列表的起始位置 | +| | \#include <string.h> | char \*strchr(const char \*s, int c); | 在字符串中定位字符 | +| | \#include <string.h> | int strcmp(const char \*s1, const char \*s2); | 比较字符串 | +| | \#include <string.h> | size_t strcspn(const char \*s, const char \*reject); | 获取前缀子串的长度 | +| | \#include <string.h> | char \*strdup(const char \*s); | 字符串拷贝到新建的位置处 | +| | \#include <string.h> | size_t strlen(const char \*s); | 计算字符串长度 | +| | \#include <strings.h> | int strncasecmp(const char \*s1, const char \*s2, size_t n); | 比较固定长度字符串(忽略大小写) | +| | \#include <strings.h> | int strcasecmp(const char \*s1, const char \*s2); | 比较字符串(忽略大小写) | +| | \#include <string.h> | int strncmp(const char \*s1, const char \*s2, size_t n); | 比较字符串(指定长度) | +| | \#include <string.h> | char \*strrchr(const char \*s, int c); | 在字符串中定位字符 | +| | \#include <string.h> | char \*strstr(const char \*haystack, const char \*needle); | 寻找指定的子串 | +| | \#include <stdlib.h> | long int strtol(const char \*nptr, char \*\*endptr, int base); | 将字符串转换为long型整数 | +| | \#include <stdlib.h> | unsigned long int strtoul(const char \*nptr, char \*\*endptr, int base); | 将字符串转换为unsigned long型整数 | +| | \#include <stdlib.h> | unsigned long long int strtoull(const char \*nptr, char \*\*endptr,int base); | 将字符串转换为unsigned long long型整数 | +| | \#include <regex.h> | int regcomp(regex_t \*preg, const char \*regex, int cflags); | 编译正则表达式 | +| | \#include <regex.h> | int regexec(const regex_t \*preg, const char \*string, size_t nmatch,regmatch_t pmatch[], int eflags); | 匹配正则表达式 | +| | \#include <regex.h> | void regfree(regex_t \*preg); | 释放正则表达式 | +| | \#include <string.h> | char \*strerror(int errnum); | 返回描述错误号的字符串 | +| math | \#include <stdlib.h> | int abs(int i); | 取绝对值 | +| | \#include <math.h> | double log(double x); | 自然对数函数 | +| | \#include <math.h> | double pow(double x, double y); | 求x的指数y次幂 | +| | \#include <math.h> | double round(double x); | 从零开始,舍入到最接近的整数 | +| | \#include <math.h> | double sqrt(double x); | 平方根 | +| IO | \#include <stdio.h> | void clearerr(FILE \*stream); | 清除流的文件结尾和错误指示 | +| | \#include <stdio.h> | int fclose(FILE \*stream); | 关闭文件流 | +| | \#include <stdio.h> | FILE \*fdopen(int fd, const char \*mode); | 通过文件描述符打开文件流 | +| | \#include <stdio.h> | int feof(FILE \*stream); | 检测返回文件末尾指示位 | +| | \#include <stdio.h> | int fflush(FILE \*stream); | 刷新流 | +| | \#include <stdio.h> | char \*fgets(char \*s, int size, FILE \*stream); | 读取流的下一行 | +| | \#include <stdio.h> | int fileno(FILE \*stream); | 返回流的文件描述符 | +| | \#include <stdio.h> | FILE \*fopen(const char \*path, const char \*mode); | 打开流 | +| | \#include <stdio.h> | int fputs(const char \*s, FILE \*stream); | 向指定流写入一行 | +| | \#include <stdio.h> | size_t fread(void \*ptr, size_t size, size_t nmemb, FILE \*stream); | 读一个流 | +| | \#include <stdio.h> | int fseek(FILE \*stream, long offset, int whence); | 设置流指针的位置 | +| | \#include <stdio.h> | long ftell(FILE \*stream); | 获取流指针的位置 | +| | \#include <stdio.h> | size_t fwrite(const void \*ptr, size_t size, size_t nmemb,FILE \*stream); | 向流写入 | +| | \#include <stdio.h> | void perror(const char \*s); | 打印系统错误信息 | +| | \#include <stdio.h> | void rewind(FILE \*stream); | 重新定位流 | +| | \#include <unistd.h> | ssize_t write(int fd, const void \*buf, size_t size); | 写文件内容 | +| | \#include <unistd.h> | ssize_t read(int fd, void \*buf, size_t size); | 读文件内容 | +| net | \#include <sys/socket.h> | void freeaddrinfo(struct addrinfo \*res); | 释放调用getaddrinfo所分配的动态内存 | +| | \#include <sys/socket.h> | int getaddrinfo(const char \*restrict nodename,const char \*restrict servname,const struct addrinfo \*restrict hints,struct addrinfo \*\*restrict res); | 网络地址和服务转换 | +| | \#include <sys/socket.h> | int getnameinfo(const struct sockaddr \*restrict sa, socklen_t salen,char \*restrict node, socklen_t nodelen, char \*restrict service,socklen_t servicelen, int flags); | 以协议无关的方式进行地址到名称的转换 | +| | \#include <net/if.h> | unsigned int if_nametoindex(const char \*ifname); | 通过网络接口名得到索引 | +| | \#include <arpa/inet.h> | in_addr_t inet_addr(const char \*cp); | 网络主机地址点分十进制形式转换位二进制形式 | +| | \#include <arpa/inet.h> | char \*inet_ntoa(struct in_addr in); | 网络主机地址二进制形式转换位点分十进制形式 | +| | \#include <arpa/inet.h> | const char \*inet_ntop(int af, const void \*src,char \*dst, socklen_t size); | 网络地址转换 | +| | \#include <arpa/inet.h> | int inet_pton(int af, const char \*src, void \*dst); | 网络地址转换 | +| | \#include <sys/socket.h> | int listen(int sockfd, int backlog); | 监听套接字 | +| | \#include <sys/socket.h> | ssize_t recvmsg(int sockfd, struct msghdr \*msg, int flags); | 从套接字接收消息.只支持iov大小为1的场景,且不支持ancillary消息 | +| | \#include <sys/socket.h> | ssize_t send(int sockfd, const void \*buf, size_t len, int flags); | 从socket发送消息 | +| | \#include <sys/socket.h> | ssize_t sendmsg(int sockfd, const struct msghdr \*msg, int flags); | 从socket发送消息。不支持ancillary消息 | +| | \#include <sys/socket.h> | ssize_t sendto(int sockfd, const void \*buf, size_t len, int flags,const struct sockaddr \*dest_addr, socklen_t addrlen); | 从socket发送消息 | +| | \#include <sys/socket.h> | int setsockopt(int sockfd, int level, int optname,const void \*optval, socklen_t optlen); | 设置与套接字关联的选项 | +| mem | \#include <string.h> | int memcmp(const void \*s1, const void \*s2, size_t n); | 内存比较 | +| | \#include <string.h> | void \*memcpy(void \*dest, const void \*src, size_t n); | 内存拷贝 | +| | \#include <string.h> | void \*memset(void \*s, int c, size_t n); | 内存初始化 | +| | \#include <stdlib.h> | void \*realloc(void \*ptr, size_t size); | 重分配内存 | +| | \#include <stdlib.h> | void \*malloc(size_t size); | 动态分配内存块大小 | +| | \#include <stdlib.h> | void free(void \*ptr); | 释放ptr所指向的内存空间 | +| IPC | \#include <semaphore.h> | int sem_timedwait(sem_t \*sem, const struct timespec \*abs_timeout); | 计时锁定信号量 | +| | \#include <semaphore.h> | int sem_destroy(sem_t \*sem); | 销毁指定的无名信号量 | +| | \#include | int sem_trywait(sem_t *sem); | 尝试申请一个信号量 | +| | \#include <semaphore.h> | int sem_init(sem_t \*sem, int pshared, unsigned int value); | 创建并初始化一个无名信号量 | +| | \#include <semaphore.h> | int sem_post(sem_t \*sem); | 增加信号量计数 | +| | \#include <semaphore.h> | int sem_wait(sem_t \*sem); | 获取信号量 | +| | \#include <mqueue.h> | mqd_t mq_open(const char \*mqName, int openFlag, ...); | 此API用于打开一个具有指定名称的已有消息队列或创建一个新的消息队列 | +| | \#include <mqueue.h> | int mq_close(mqd_t personal); | 此API用于关闭具有指定描述符的消息队列 | +| | \#include <mqueue.h> | int mq_unlink(const char \*mqName); | 此API用于删除具有指定名称的消息队列 | +| | \#include <mqueue.h> | int mq_send(mqd_t personal, const char \*msg, size_t msgLen, unsigned int msgPrio); | 此API用于将具有指定内容和长度的消息放入具有指定描述符的消息队列中 | +| | \#include <mqueue.h> | ssize_t mq_receive(mqd_t personal, char \*msg, size_t msgLen, unsigned int \*msgPrio); | 此API用于从具有指定描述符的消息队列中删除最老的消息,并将其放入msg_ptr所指向的缓冲区中 | +| | \#include <mqueue.h> | int mq_timedsend(mqd_t personal, const char \*msg, size_t msgLen, unsigned int msgPrio, const struct timespec \*absTimeout) | 此API用于在预定时间将具有指定内容和长度的消息放入具有描述符的消息队列中 | +| | \#include <mqueue.h> | ssize_t mq_timedreceive(mqd_t personal, char \*msg, size_t msgLen, unsigned int \*msgPrio, const struct timespec \*absTimeout); | 此API用于从具有指定描述符的消息队列消息中获取具有指定消息内容和长度的消息 | +| | \#include <mqueue.h> | int mq_setattr(mqd_t mqdes, const struct mq_attr \*__restrict newattr, struct mq_attr \*__restrict oldattr); | 设置描述符指定的消息队列属性 | +| | version | \#include <libc.h> | const char \*libc_get_version_string(void); | +| | \#include <libc.h> | int libc_get_version(void); | 获取libc版本号 | ### 注意事项 diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt.md b/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt.md index df70260e95ded6682c67e62a2cf3470d3cbd3d2e..f44a5e3ad14a08881f23593a7393f66505d1c145 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-interrupt.md @@ -42,22 +42,25 @@ OpenHarmony LiteOS-M内核的中断模块提供下面几种功能,接口详细 **表1** 中断模块接口 -| 功能分类 | 接口名 | 描述 | +| 功能分类 | 接口名 | 描述 | | -------- | -------- | -------- | -| 创建、删除中断 | HalHwiCreate | 中断创建,注册中断号、中断触发模式、中断优先级、中断处理程序。中断被触发时,会调用该中断处理程序。 | -| HalHwiDelete | 根据指定的中断号,删除中断。 | -| 打开、关闭中断 | LOS_IntUnLock | 开中断,使能当前处理器所有中断响应。 | -| LOS_IntLock | 关中断,关闭当前处理器所有中断响应。 | -| LOS_IntRestore | 恢复到使用LOS_IntLock、LOS_IntUnLock操作之前的中断状态。 | +| 创建、删除中断 | LOS_HwiCreate | 中断创建,注册中断号、中断触发模式、中断优先级、中断处理程序。中断被触发时,会调用该中断处理程序。 | +| | LOS_HwiDelete | 根据指定的中断号,删除中断。 | +| 打开、关闭中断 | LOS_IntUnLock | 开中断,使能当前处理器所有中断响应。 | +| | LOS_IntLock | 关中断,关闭当前处理器所有中断响应。 | +| | LOS_IntRestore | 恢复到使用LOS_IntLock、LOS_IntUnLock操作之前的中断状态。 | +| 使能和屏蔽指定中断 | LOS_HwiDisable | 中断屏蔽。(通过设置寄存器,禁止CPU响应该中断) | +| | LOS_HwiEnable | 中断使能。(通过设置寄存器,允许CPU响应该中断) | +| 设置中断优先级 | LOS_HwiSetPriority | 设置中断优先级。 | +| 触发中断 | LOS_HwiTrigger | 触发中断。(通过写中断控制器的相关寄存器模拟外部中断) | +| 清除中断寄存器状态 | LOS_HwiClear | 清除中断号对应的中断寄存器的状态位,此接口依赖中断控制器版本,非必需。 | ## 开发流程 -1. 调用中断创建接口HalHwiCreate创建中断。 - -2. 调用TestHwiTrigger接口触发指定中断(该接口在测试套中定义,通过写中断控制器的相关寄存器模拟外部中断,一般的外设设备,不需要执行这一步)。 - -3. 调用HalHwiDelete接口删除指定中断,此接口根据实际情况使用,判断是否需要删除中断。 +1. 调用中断创建接口LOS_HwiCreate创建中断。 +2. 调用中断触发接口LOS_HwiTrigger触发中断。 +3. 调用LOS_HwiDelete接口删除指定中断,此接口根据实际情况使用,判断是否需要删除中断。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** @@ -101,7 +104,7 @@ static UINT32 Example_Interrupt(VOID) HWI_ARG_T arg = 0; /*创建中断*/ - ret = HalHwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, arg); + ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, arg); if(ret == LOS_OK){ printf("Hwi create success!\n"); } else { @@ -109,11 +112,17 @@ static UINT32 Example_Interrupt(VOID) return LOS_NOK; } - /* 延时50个Ticks, 当有硬件中断发生时,会调用函数HwiUsrIrq*/ - LOS_TaskDelay(50); + /*触发中断*/ + ret = LOS_HwiTrigger(HWI_NUM_TEST); + if(ret == LOS_OK){ + printf("Hwi trigger success!\n"); + } else { + printf("Hwi trigger failed!\n"); + return LOS_NOK; + } /*删除中断*/ - ret = HalHwiDelete(HWI_NUM_TEST); + ret = LOS_HwiDelete(HWI_NUM_TEST); if(ret == LOS_OK){ printf("Hwi delete success!\n"); } else { @@ -132,5 +141,7 @@ static UINT32 Example_Interrupt(VOID) ``` Hwi create success! +in the func HwiUsrIrq +Hwi trigger success! Hwi delete success! ``` diff --git a/zh-cn/device-dev/kernel/kernel-mini-basic-task.md b/zh-cn/device-dev/kernel/kernel-mini-basic-task.md index e7d56d101aed42bad9a006fa21915a00c67282c2..97074adc9157f988de2971b71a9066abee05f444 100644 --- a/zh-cn/device-dev/kernel/kernel-mini-basic-task.md +++ b/zh-cn/device-dev/kernel/kernel-mini-basic-task.md @@ -109,32 +109,34 @@ OpenHarmony LiteOS-M内核的任务管理模块提供下面几种功能,接口 **表1** 任务管理模块接口 -| 功能分类 | 接口名 | 描述 | +| 功能分类 | 接口名 | 描述 | | -------- | -------- | -------- | -| 创建和删除任务 | LOS_TaskCreateOnly | 创建任务,并使该任务进入suspend状态,不对该任务进行调度。如果需要调度,可以调用LOS_TaskResume使该任务进入ready状态。 | -| LOS_TaskCreate | 创建任务,并使该任务进入ready状态,如果就绪队列中没有更高优先级的任务,则运行该任务。 | -| LOS_TaskDelete | 删除指定的任务。 | -| 控制任务状态 | LOS_TaskResume | 恢复挂起的任务,使该任务进入ready状态。 | -| LOS_TaskSuspend | 挂起指定的任务,然后切换任务。 | -| LOS_TaskJoin | 挂起当前任务,等待指定任务运行结束并回收其任务控制块资源 | -| LOS_TaskDelay | 任务延时等待,释放CPU,等待时间到期后该任务会重新进入ready状态。传入参数为Tick数目。 | -| LOS_Msleep | 传入参数为毫秒数,转换为Tick数目,调用LOS_TaskDelay。 | -| LOS_TaskYield | 当前任务时间片设置为0,释放CPU,触发调度运行就绪任务队列中优先级最高的任务。 | -| 控制任务调度 | LOS_TaskLock | 锁任务调度,但任务仍可被中断打断。 | -| LOS_TaskUnlock | 解锁任务调度。 | -| LOS_Schedule | 触发任务调度。 | -| 控制任务优先级 | LOS_CurTaskPriSet | 设置当前任务的优先级。 | -| LOS_TaskPriSet | 设置指定任务的优先级。 | -| LOS_TaskPriGet | 获取指定任务的优先级。 | -| 获取任务信息 | LOS_CurTaskIDGet | 获取当前任务的ID。 | -| LOS_NextTaskIDGet | 获取任务就绪队列中优先级最高的任务的ID。 | -| LOS_NewTaskIDGet | 等同LOS_NextTaskIDGet。 | -| LOS_CurTaskNameGet | 获取当前任务的名称。 | -| LOS_TaskNameGet | 获取指定任务的名称。 | -| LOS_TaskStatusGet | 获取指定任务的状态。 | -| LOS_TaskInfoGet | 获取指定任务的信息,包括任务状态、优先级、任务栈大小、栈顶指针SP、任务入口函数、已使用的任务栈大小等。 | -| LOS_TaskIsRunning | 获取任务模块是否已经开始调度运行。 | -| 任务信息维测 | LOS_TaskSwitchInfoGet | 获取任务切换信息,需要开启宏LOSCFG_BASE_CORE_EXC_TSK_SWITCH。 | +| 创建和删除任务 | LOS_TaskCreateOnly | 创建任务,并使该任务进入suspend状态,不对该任务进行调度。如果需要调度,可以调用LOS_TaskResume使该任务进入ready状态。 | +| | LOS_TaskCreate | 创建任务,并使该任务进入ready状态,如果就绪队列中没有更高优先级的任务,则运行该任务。 | +| | LOS_TaskDelete | 删除指定的任务。 | +| 控制任务状态 | LOS_TaskResume | 恢复挂起的任务,使该任务进入ready状态。 | +| | LOS_TaskSuspend | 挂起指定的任务,然后切换任务。 | +| | LOS_TaskJoin | 挂起当前任务,等待指定任务运行结束并回收其任务控制块资源。 | +| | LOS_TaskDetach | 修改任务的joinable属性为detach属性,detach属性的任务运行结束会自动回收任务控制块资源。 | +| | LOS_TaskDelay | 任务延时等待,释放CPU,等待时间到期后该任务会重新进入ready状态。传入参数为Tick数目。 | +| | LOS_Msleep | 传入参数为毫秒数,转换为Tick数目,调用LOS_TaskDelay。 | +| | LOS_TaskYield | 当前任务时间片设置为0,释放CPU,触发调度运行就绪任务队列中优先级最高的任务。 | +| 控制任务调度 | LOS_TaskLock | 锁任务调度,但任务仍可被中断打断。 | +| | LOS_TaskUnlock | 解锁任务调度。 | +| | LOS_Schedule | 触发任务调度。 | +| 控制任务优先级 | LOS_CurTaskPriSet | 设置当前任务的优先级。 | +| | LOS_TaskPriSet | 设置指定任务的优先级。 | +| | LOS_TaskPriGet | 获取指定任务的优先级。 | +| 获取任务信息 | LOS_CurTaskIDGet | 获取当前任务的ID。 | +| | LOS_NextTaskIDGet | 获取任务就绪队列中优先级最高的任务的ID。 | +| | LOS_NewTaskIDGet | 等同LOS_NextTaskIDGet。 | +| | LOS_CurTaskNameGet | 获取当前任务的名称。 | +| | LOS_TaskNameGet | 获取指定任务的名称。 | +| | LOS_TaskStatusGet | 获取指定任务的状态。 | +| | LOS_TaskInfoGet | 获取指定任务的信息,包括任务状态、优先级、任务栈大小、栈顶指针SP、任务入口函数、已使用的任务栈大小等。 | +| | LOS_TaskIsRunning | 获取任务模块是否已经开始调度运行。 | +| 任务信息维测 | LOS_TaskSwitchInfoGet | 获取任务切换信息,需要开启宏LOSCFG_BASE_CORE_EXC_TSK_SWITCH。 | +| 回收任务栈资源 | LOS_TaskResRecycle | 回收所有待回收的任务栈资源。 | ## 开发流程 diff --git a/zh-cn/device-dev/kernel/kernel-small-basic-time.md b/zh-cn/device-dev/kernel/kernel-small-basic-time.md index 7991f2a1133c29c13ffbb258aefbb3418d20e9d8..57d1c19f904b7aed33ff8732faa9fb494906881c 100644 --- a/zh-cn/device-dev/kernel/kernel-small-basic-time.md +++ b/zh-cn/device-dev/kernel/kernel-small-basic-time.md @@ -36,8 +36,12 @@ OpenHarmony LiteOS-A内核的时间管理提供下面几种功能,接口详细 | -------- | -------- | -------- | | 时间转换 | LOS_MS2Tick | 毫秒转换成Tick | | | LOS_Tick2MS |Tick转换成毫秒| -| 时间统计 | LOS_TickCountGet | 获取当前Tick数 | +| 时间统计 | LOS_SysClockGet | 获取系统时钟 | +| | LOS_TickCountGet | 获取当前Tick数 | | | LOS_CyclePerTickGet |每个Tick的cycle数| +| | LOS_CurrNanosec |获取自系统启动以来的纳秒数| +| 延时管理 | LOS_UDelay |以us为单位的忙等,但可以被优先级更高的任务抢占| +| | LOS_MDelay |以ms为单位的忙等,但可以被优先级更高的任务抢占| ### 开发流程