diff --git a/compat/posix/src/map_error.c b/compat/posix/src/map_error.c index 352b3bf3491704c2e1cdd7d20a5e2be2a4451594..53e8432b21010f2b4157a353bd6f29340d8d60e7 100644 --- a/compat/posix/src/map_error.c +++ b/compat/posix/src/map_error.c @@ -38,7 +38,7 @@ int map_errno(UINT32 err) { if (err == LOS_OK) { - return ENOERR; + return ENOERR; //成功 } switch (err) { case LOS_ERRNO_QUEUE_INVALID: @@ -48,24 +48,24 @@ int map_errno(UINT32 err) case LOS_ERRNO_QUEUE_CREAT_PTR_NULL: case LOS_ERRNO_QUEUE_PARA_ISZERO: case LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG: - errno = EINVAL; + errno = EINVAL; //Invalid argument 无效的参数 break; case LOS_ERRNO_QUEUE_ISFULL: case LOS_ERRNO_QUEUE_ISEMPTY: - errno = EAGAIN; + errno = EAGAIN;//资源暂时不可用 break; case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY: - errno = ENOSPC; + errno = ENOSPC;// No space left on device 设备上没有空间 break; case LOS_ERRNO_QUEUE_TIMEOUT: errno = ETIMEDOUT; break; case LOS_ERRNO_QUEUE_CB_UNAVAILABLE: - errno = ENFILE; + errno = ENFILE;//File table overflow 打开太多的文件系统 break; case LOS_ERRNO_QUEUE_READ_IN_INTERRUPT: case LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT: - errno = EINTR; + errno = EINTR;//Interrupted system call 系统调用被中断 break; case LOS_ERRNO_TSK_ID_INVALID: case LOS_ERRNO_TSK_PTR_NULL: diff --git a/compat/posix/src/misc.c b/compat/posix/src/misc.c index f1138467e7d74ccf120af5806ce0a53b2d6cbc64..9f89f329d7a082c1333d2e3f55e7a67a6dc62404 100644 --- a/compat/posix/src/misc.c +++ b/compat/posix/src/misc.c @@ -146,12 +146,12 @@ long sysconf(int name) return -1; } } - +/// 获取当前任务ID pid_t getpid(void) { return ((LosTaskCB *)(OsCurrTaskGet()))->taskID; } - +/// 获取当前进程资源限制。 int getrlimit(int resource, struct rlimit *rlim) { unsigned int intSave; @@ -185,6 +185,7 @@ int getrlimit(int resource, struct rlimit *rlim) #ifndef NR_OPEN_DEFAULT #define NR_OPEN_DEFAULT 1024 #endif +/// 重新设置当前进程资源限制。 int setrlimit(int resource, const struct rlimit *rlim) { unsigned int intSave; diff --git a/compat/posix/src/pthread.c b/compat/posix/src/pthread.c index ee2bd0d116933faccd1bb9a05c36885a049c2833..9bb8fa4fbdf39490ee4ef78ea0e58f4a646032c5 100644 --- a/compat/posix/src/pthread.c +++ b/compat/posix/src/pthread.c @@ -287,7 +287,7 @@ ERROR_OUT: return map_errno(ret); } - +/// 线程退出 void pthread_exit(void *retVal) { _pthread_data *self = pthread_get_self_data(); @@ -793,7 +793,7 @@ void pthread_cleanup_pop_inner(struct pthread_cleanup_buffer *buffer, int execut } /* - * Set the cpu affinity mask for the thread + * Set the cpu affinity mask for the thread | 设置线程与CPU的亲和性 */ int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t* cpuset) { @@ -806,7 +806,7 @@ int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t* } /* - * Get the cpu affinity mask from the thread + * Get the cpu affinity mask from the thread | 获取线程与CPU的亲和性 */ int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t* cpuset) { diff --git a/compat/posix/src/sched.c b/compat/posix/src/sched.c index 442cb3229c21b347824e239e4b6a4b1982909440..60a91d4b2077247b3bed36a9a6090b84ebdb35d5 100644 --- a/compat/posix/src/sched.c +++ b/compat/posix/src/sched.c @@ -138,7 +138,7 @@ int __sched_cpucount(size_t set_size, const cpu_set_t* set) return count; } - +/// 任务让出CPU int sched_yield() { (void)LOS_TaskYield(); diff --git a/kernel/base/include/los_process_pri.h b/kernel/base/include/los_process_pri.h index 681c110629f7f943bd4253e7d1f9aec8c21106c2..178cdbc65639fc9dae95beccd90ffdc9d546e166 100644 --- a/kernel/base/include/los_process_pri.h +++ b/kernel/base/include/los_process_pri.h @@ -129,7 +129,7 @@ typedef struct ProcessCB { #ifdef LOSCFG_KERNEL_CPUP OsCpupBase *processCpup; /**< Process cpu usage | 进程占用CPU情况统计*/ #endif - struct rlimit *resourceLimit; + struct rlimit *resourceLimit; ///< 每个进程在运行时系统不会无限制的允许单个进程不断的消耗资源,因此都会设置资源限制。 } LosProcessCB; #define CLONE_VM 0x00000100 ///< 子进程与父进程运行于相同的内存空间 diff --git a/kernel/include/los_typedef.h b/kernel/include/los_typedef.h index 7c47e9a0e7d60e2d0202cbe90fe0b8c50fd0c0fe..d5836d14431ca39753488f402c64d61347c3e03d 100644 --- a/kernel/include/los_typedef.h +++ b/kernel/include/los_typedef.h @@ -109,61 +109,61 @@ typedef size_t BOOL; #ifndef USER #define USER #endif - +/// 常用错误码对照表 #ifndef LOS_OK -#define LOS_OK 0 +#define LOS_OK 0 ///< Success 成功 #endif #ifndef LOS_NOK -#define LOS_NOK 1 +#define LOS_NOK 1 ///< fail 失败 #endif #ifndef LOS_EPERM -#define LOS_EPERM 1 +#define LOS_EPERM 1 ///< 操作不允许 Operation not permitted #endif #ifndef LOS_ESRCH -#define LOS_ESRCH 3 +#define LOS_ESRCH 3 ///< No such process 没有这样的进程(暂不支持) #endif #ifndef LOS_EINTR -#define LOS_EINTR 4 +#define LOS_EINTR 4 ///< Interrupted system call 系统调用被中断 #endif #ifndef LOS_EBADF -#define LOS_EBADF 9 +#define LOS_EBADF 9 ///< Bad file number 坏的文件描述符 #endif #ifndef LOS_ECHILD -#define LOS_ECHILD 10 +#define LOS_ECHILD 10 ///< No child processes 没有子进程(暂不支持) #endif #ifndef LOS_EAGAIN -#define LOS_EAGAIN 11 +#define LOS_EAGAIN 11 ///< Try again 资源暂时不可用 #endif #ifndef LOS_ENOMEM -#define LOS_ENOMEM 12 +#define LOS_ENOMEM 12 ///< Out of memory 内存溢出 #endif #ifndef LOS_EACCES -#define LOS_EACCES 13 +#define LOS_EACCES 13 ///< Permission denied 拒绝许可 #endif #ifndef LOS_EFAULT -#define LOS_EFAULT 14 +#define LOS_EFAULT 14 ///< Bad address 错误的地址 #endif #ifndef LOS_EBUSY -#define LOS_EBUSY 16 +#define LOS_EBUSY 16 ///< Device or resource busy 设备或资源忙 #endif #ifndef LOS_EINVAL -#define LOS_EINVAL 22 +#define LOS_EINVAL 22 ///< Invalid argument 无效的参数 #endif #ifndef LOS_EDEADLK -#define LOS_EDEADLK 35 +#define LOS_EDEADLK 35 ///< Resource deadlock would occur 资源死锁错误 #endif #ifndef LOS_EOPNOTSUPP diff --git a/zzz/git/push.sh b/zzz/git/push.sh index 0bef7e14d7c76875353731329ec841dd95cdc57f..038f49c19561a7e6b97ec62de9edfc497cf8bace 100644 --- a/zzz/git/push.sh +++ b/zzz/git/push.sh @@ -1,5 +1,5 @@ git add -A -git commit -m ' Posix 接口注释 +git commit -m ' Posix | 系统调用 接口注释 百图画鸿蒙 + 百文说内核 + 百万注源码 => 挖透鸿蒙内核源码 鸿蒙研究站 | http://weharmonyos.com (国内) | https://weharmony.github.io (国外)