上一页 1 2 3 4 5 6 7 8 ··· 10 下一页
摘要: #include <sys/time.h> int setitimer(int which, const struct itimerval *new_value, struct itimerval *old_value); - 功能: 设置定时器(闹钟), 可以替代alarm函数, 精度微妙(us) 阅读全文
posted @ 2023-05-17 18:41 言叶以上 阅读(49) 评论(0) 推荐(0) 编辑
摘要: #include <unistd.h> unsigned int alarm(unsigned int seconds); - 功能: 设置定时器, 函数调用后开始倒计时, 当倒计时为0时, 函数会给当前进程发送一个信号:SIGALARM - 参数: seconds: 倒计时的时长, 单位:秒. - 阅读全文
posted @ 2023-05-17 18:40 言叶以上 阅读(58) 评论(0) 推荐(0) 编辑
摘要: #include <sys/types.h> #include <signal.h> int kill(pid_t pid, int sig); - 功能: 给某个进程pid, 发送某个信号sig - 参数: - pid: >0: 将信号发送给指定的进程 =0: 将信号发送给当前的进程组 =-1: 阅读全文
posted @ 2023-05-17 18:40 言叶以上 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 信号概念 信号是 Linux 进程间通信的最古老的方式之一,是事件发生时对进程的通知机制,有时也称之为软件中断,它是在软件层次上对中断机制的一种模拟,是一种异步通信的方式。信号可以导致一个正在运行的进程被另一个正在运行的异步进程中断,转而处理某一个突发事件。 发往进程的诸多信号,通常都是源于内核。引 阅读全文
posted @ 2023-05-17 18:39 言叶以上 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 内存映射(Memory-mapped I/O)是将磁盘文件的数据映射到内存,用户通过修改内存就能修改磁盘文件。 mmap #include <sys/mman.h> void *mmap(void *addr, size_t length, int prot, int flags, int fd, 阅读全文
posted @ 2023-05-17 18:39 言叶以上 阅读(40) 评论(0) 推荐(0) 编辑
摘要: chatA.c //有名管道实现简单版聊天功能 #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> #include <fcntl.h> #in 阅读全文
posted @ 2023-05-17 18:38 言叶以上 阅读(52) 评论(0) 推荐(0) 编辑
摘要: /* 实现 ps aux | grep xxx 父子进程间通信 子进程 : ps aux, 子进程结束后将数据发送给父进程 父进程 : 获取到数据,guolv pipe() execlp() 子进程将标准输出 stdout_fileno 重定向到管道的写端 dup2() */ #include <s 阅读全文
posted @ 2023-05-17 18:38 言叶以上 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 进程间通信 进程是一个独立的资源分配单元,不同进程(这里所说的进程通常指的是用户进程)之间的资源是独立的,没有关联,不能在一个进程中直接访问另一个进程的资源。 不同的进程需要进行信息的交互和状态传递(如: 数据传输/通知事件/资源共享/进程控制) , 因此需要进程间通信(IPC: Inter Pro 阅读全文
posted @ 2023-05-17 18:37 言叶以上 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 进程回收 在每个进程退出的时候,内核释放该进程所有的资源、包括打开的文件、占用的内存等。但是仍然为其保留一定的信息,这些信息主要主要指进程控制块PCB的信息(包括进程号、退出状态、运行时间等)。 父进程可以通过调用wait或waitpid得到它的退出状态同时彻底清除掉这个进程。 wait() 和 w 阅读全文
posted @ 2023-05-17 18:36 言叶以上 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 进程退出 #include <stdlib.h> void exit(int status); #include <unistd.h> void _exit(int status); /* #include<stdlib.h> void exit(int status); #include<unis 阅读全文
posted @ 2023-05-17 18:36 言叶以上 阅读(24) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 10 下一页