同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
This section describes the key differences between the standard library carried by the OpenHarmony kernel and the Linux standard library. For more information, see the API document of the C library.
mmap prototype: void *mmap (void *addr, size_t length, int prot, int flags, int fd, off_t offset)
The lifecycle implementation of fd is different from that of Linux glibc. To be specific, the glibc can release the fd handle immediately after successfully invoking the mmap for mapping. In the OpenHarmony kernel, you are not allowed to close fd immediately after the mapping is successful. You can close fd only after the munmap is canceled. If you do not close the fd, the operating system reclaims it when the process exits.
For Linux OS:
int main(int argc, char *argv[])
{
int fd;
void *addr = NULL;
...
fd = open(argv[1], O_RDONLY);
if (fd == -1){
perror("open");
exit(EXIT_FAILURE);
}
addr = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, offset);
if (addr == MAP_FAILED) {
perror("mmap");
exit(EXIT_FAILURE);
}
close(fd); /* OpenHarmony does not support closing fd immediately after the mapping is successful. */
...
exit(EXIT_SUCCESS);
}
For OpenHarmony:
int main(int argc, char *argv[])
{
int fd;
void *addr = NULL;
...
fd = open(argv[1], O_RDONLY);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
}
addr = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, offset);
if (addr == MAP_FAILED) {
perror("mmap");
exit(EXIT_FAILURE);
}
...
munmap(addr, length);
close(fd); /* Close fd after the munmap is canceled. */
exit(EXIT_SUCCESS);
}
System directories: include /dev, /proc, /app, /bin, /data, /etc, /lib, /system and /usr. Users do not have the permission to modify the directories and mount devices.
User directory: refers to /storage. Users can create, read, and write files in this directory, but cannot mount devices.
In addition to the system and user directories, you can create folders to mount devices. Note that a mounted folder and its subfolders cannot be mounted repeatedly or in nested mode. A non-empty folder cannot be mounted.
The time precision of OpenHarmony is tick, with the default value of 10 ms/tick. The discrepancy of the sleep and timeout functions is less than or equal to 2 ticks.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。