Posix | 系统调用 接口注释

    百图画鸿蒙 + 百文说内核 + 百万注源码  => 挖透鸿蒙内核源码
    鸿蒙研究站 | http://weharmonyos.com (国内)
              | https://weharmony.github.io (国外)
    oschina | https://my.oschina.net/weharmony
    博客园 | https://www.cnblogs.com/weharmony/
    知乎 | https://www.zhihu.com/people/weharmonyos
    csdn | https://blog.csdn.net/kuangyufei
    51cto | https://harmonyos.51cto.com/column/34
    掘金 | https://juejin.cn/user/756888642000808
    公众号 | 鸿蒙研究站 (weharmonyos)
上级 cf839f91
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
int map_errno(UINT32 err) int map_errno(UINT32 err)
{ {
if (err == LOS_OK) { if (err == LOS_OK) {
return ENOERR; return ENOERR; //成功
} }
switch (err) { switch (err) {
case LOS_ERRNO_QUEUE_INVALID: case LOS_ERRNO_QUEUE_INVALID:
...@@ -48,24 +48,24 @@ int map_errno(UINT32 err) ...@@ -48,24 +48,24 @@ int map_errno(UINT32 err)
case LOS_ERRNO_QUEUE_CREAT_PTR_NULL: case LOS_ERRNO_QUEUE_CREAT_PTR_NULL:
case LOS_ERRNO_QUEUE_PARA_ISZERO: case LOS_ERRNO_QUEUE_PARA_ISZERO:
case LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG: case LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG:
errno = EINVAL; errno = EINVAL; //Invalid argument 无效的参数
break; break;
case LOS_ERRNO_QUEUE_ISFULL: case LOS_ERRNO_QUEUE_ISFULL:
case LOS_ERRNO_QUEUE_ISEMPTY: case LOS_ERRNO_QUEUE_ISEMPTY:
errno = EAGAIN; errno = EAGAIN;//资源暂时不可用
break; break;
case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY: case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY:
errno = ENOSPC; errno = ENOSPC;// No space left on device 设备上没有空间
break; break;
case LOS_ERRNO_QUEUE_TIMEOUT: case LOS_ERRNO_QUEUE_TIMEOUT:
errno = ETIMEDOUT; errno = ETIMEDOUT;
break; break;
case LOS_ERRNO_QUEUE_CB_UNAVAILABLE: case LOS_ERRNO_QUEUE_CB_UNAVAILABLE:
errno = ENFILE; errno = ENFILE;//File table overflow 打开太多的文件系统
break; break;
case LOS_ERRNO_QUEUE_READ_IN_INTERRUPT: case LOS_ERRNO_QUEUE_READ_IN_INTERRUPT:
case LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT: case LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT:
errno = EINTR; errno = EINTR;//Interrupted system call 系统调用被中断
break; break;
case LOS_ERRNO_TSK_ID_INVALID: case LOS_ERRNO_TSK_ID_INVALID:
case LOS_ERRNO_TSK_PTR_NULL: case LOS_ERRNO_TSK_PTR_NULL:
......
...@@ -146,12 +146,12 @@ long sysconf(int name) ...@@ -146,12 +146,12 @@ long sysconf(int name)
return -1; return -1;
} }
} }
/// 获取当前任务ID
pid_t getpid(void) pid_t getpid(void)
{ {
return ((LosTaskCB *)(OsCurrTaskGet()))->taskID; return ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
} }
/// 获取当前进程资源限制。
int getrlimit(int resource, struct rlimit *rlim) int getrlimit(int resource, struct rlimit *rlim)
{ {
unsigned int intSave; unsigned int intSave;
...@@ -185,6 +185,7 @@ int getrlimit(int resource, struct rlimit *rlim) ...@@ -185,6 +185,7 @@ int getrlimit(int resource, struct rlimit *rlim)
#ifndef NR_OPEN_DEFAULT #ifndef NR_OPEN_DEFAULT
#define NR_OPEN_DEFAULT 1024 #define NR_OPEN_DEFAULT 1024
#endif #endif
/// 重新设置当前进程资源限制。
int setrlimit(int resource, const struct rlimit *rlim) int setrlimit(int resource, const struct rlimit *rlim)
{ {
unsigned int intSave; unsigned int intSave;
......
...@@ -287,7 +287,7 @@ ERROR_OUT: ...@@ -287,7 +287,7 @@ ERROR_OUT:
return map_errno(ret); return map_errno(ret);
} }
/// 线程退出
void pthread_exit(void *retVal) void pthread_exit(void *retVal)
{ {
_pthread_data *self = pthread_get_self_data(); _pthread_data *self = pthread_get_self_data();
...@@ -793,7 +793,7 @@ void pthread_cleanup_pop_inner(struct pthread_cleanup_buffer *buffer, int execut ...@@ -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) 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* ...@@ -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) int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t* cpuset)
{ {
......
...@@ -138,7 +138,7 @@ int __sched_cpucount(size_t set_size, const cpu_set_t* set) ...@@ -138,7 +138,7 @@ int __sched_cpucount(size_t set_size, const cpu_set_t* set)
return count; return count;
} }
/// 任务让出CPU
int sched_yield() int sched_yield()
{ {
(void)LOS_TaskYield(); (void)LOS_TaskYield();
......
...@@ -129,7 +129,7 @@ typedef struct ProcessCB { ...@@ -129,7 +129,7 @@ typedef struct ProcessCB {
#ifdef LOSCFG_KERNEL_CPUP #ifdef LOSCFG_KERNEL_CPUP
OsCpupBase *processCpup; /**< Process cpu usage | 进程占用CPU情况统计*/ OsCpupBase *processCpup; /**< Process cpu usage | 进程占用CPU情况统计*/
#endif #endif
struct rlimit *resourceLimit; struct rlimit *resourceLimit; ///< 每个进程在运行时系统不会无限制的允许单个进程不断的消耗资源,因此都会设置资源限制。
} LosProcessCB; } LosProcessCB;
#define CLONE_VM 0x00000100 ///< 子进程与父进程运行于相同的内存空间 #define CLONE_VM 0x00000100 ///< 子进程与父进程运行于相同的内存空间
......
...@@ -109,61 +109,61 @@ typedef size_t BOOL; ...@@ -109,61 +109,61 @@ typedef size_t BOOL;
#ifndef USER #ifndef USER
#define USER #define USER
#endif #endif
/// 常用错误码对照表
#ifndef LOS_OK #ifndef LOS_OK
#define LOS_OK 0 #define LOS_OK 0 ///< Success 成功
#endif #endif
#ifndef LOS_NOK #ifndef LOS_NOK
#define LOS_NOK 1 #define LOS_NOK 1 ///< fail 失败
#endif #endif
#ifndef LOS_EPERM #ifndef LOS_EPERM
#define LOS_EPERM 1 #define LOS_EPERM 1 ///< 操作不允许 Operation not permitted
#endif #endif
#ifndef LOS_ESRCH #ifndef LOS_ESRCH
#define LOS_ESRCH 3 #define LOS_ESRCH 3 ///< No such process 没有这样的进程(暂不支持)
#endif #endif
#ifndef LOS_EINTR #ifndef LOS_EINTR
#define LOS_EINTR 4 #define LOS_EINTR 4 ///< Interrupted system call 系统调用被中断
#endif #endif
#ifndef LOS_EBADF #ifndef LOS_EBADF
#define LOS_EBADF 9 #define LOS_EBADF 9 ///< Bad file number 坏的文件描述符
#endif #endif
#ifndef LOS_ECHILD #ifndef LOS_ECHILD
#define LOS_ECHILD 10 #define LOS_ECHILD 10 ///< No child processes 没有子进程(暂不支持)
#endif #endif
#ifndef LOS_EAGAIN #ifndef LOS_EAGAIN
#define LOS_EAGAIN 11 #define LOS_EAGAIN 11 ///< Try again 资源暂时不可用
#endif #endif
#ifndef LOS_ENOMEM #ifndef LOS_ENOMEM
#define LOS_ENOMEM 12 #define LOS_ENOMEM 12 ///< Out of memory 内存溢出
#endif #endif
#ifndef LOS_EACCES #ifndef LOS_EACCES
#define LOS_EACCES 13 #define LOS_EACCES 13 ///< Permission denied 拒绝许可
#endif #endif
#ifndef LOS_EFAULT #ifndef LOS_EFAULT
#define LOS_EFAULT 14 #define LOS_EFAULT 14 ///< Bad address 错误的地址
#endif #endif
#ifndef LOS_EBUSY #ifndef LOS_EBUSY
#define LOS_EBUSY 16 #define LOS_EBUSY 16 ///< Device or resource busy 设备或资源忙
#endif #endif
#ifndef LOS_EINVAL #ifndef LOS_EINVAL
#define LOS_EINVAL 22 #define LOS_EINVAL 22 ///< Invalid argument 无效的参数
#endif #endif
#ifndef LOS_EDEADLK #ifndef LOS_EDEADLK
#define LOS_EDEADLK 35 #define LOS_EDEADLK 35 ///< Resource deadlock would occur 资源死锁错误
#endif #endif
#ifndef LOS_EOPNOTSUPP #ifndef LOS_EOPNOTSUPP
......
git add -A git add -A
git commit -m ' Posix 接口注释 git commit -m ' Posix | 系统调用 接口注释
百图画鸿蒙 + 百文说内核 + 百万注源码 => 挖透鸿蒙内核源码 百图画鸿蒙 + 百文说内核 + 百万注源码 => 挖透鸿蒙内核源码
鸿蒙研究站 | http://weharmonyos.com (国内) 鸿蒙研究站 | http://weharmonyos.com (国内)
| https://weharmony.github.io (国外) | https://weharmony.github.io (国外)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册