linux内核函数笔记(一)
进程管理函数
pid_t getpid();返回当前进程的标识号PID
pid_t fork();创建一个进程。
pid_t vfork();与fork()相似,vfork保证子进程先运行,在它调用exec或exit之后父进程才可能被调用。
exec函数族:用于把一个新程序载入调用进程的内存空间,来改变进程的执行代码,从而形成新进程。execve才是真正意义上的系统调
用,其他的都是在此基础上的库函数。
int execl(const char *path,const char *arg,...);
int execv(const char *path,char *const argv[]);
int execle(const char *path,const char *arg,...,char *const envp[]);
int execve(const char *path,char *const argv[],char *const envp[]);
int execlp(const char *file,const char *arg,...);
int execvp(const char *file,char *const argv[]);
pid_t wait(int *status);为了实现进程间的同步,让进程进入休眠状态,知道被唤醒。
pid_t waitpid(pid_t pid,int *status,int options);与wait相似,但区别是它要等待指定的pid进程退出。
options:WNOHANG,要求如果没有子进程退出就立即返回。
WUNTRACED,对已经停止但本不用报告状态的子进程,该调用也从等待中返回并报告状态。
unsigned int sleep(unsigned int seconds);使进程挂起指定的时间。
clock_k times(struct tms *buf);获取当前进程的时间信息。
exit()和_exit()
void _exit(int status);直接使进程停止运行,清除其在使用的内存空间,并销毁其在内核中的各种数据结构
exit在此基础上加了其他一些工序:检查文件打开情况,把文件缓冲区中的内容写回文件。
文件操作函数
int open(const char *pathname,int flags);
int open(const char *pathname,int flags,...,mode_t mode);
int create(const char *pathname,mode_t mode);
int close(int filedes);
size_t read(int filedes,void *buff,size_t nbytes);
ssize_t write(int filedes,void *buff,size_t nbytes);
off_t lseek(int filedes,off_t offset,int whence);
int dup(int oldfd);复制一个现存的文件描述符
int dup2(int oldfd,int newfd);同上
int ioctl(int d,int request,...);用来控制设备
文件属性
int access(const char *pathname,int mode);获得用户对文件的访问许可
int stat(const char *file_name,struct stat *buf);获取文件状态信息
int f
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......
/* 他通过只复制内存页面来复制一定范围内的线性地址的内容*/
00150int copy_page_tables(unsigned long from,unsigned long to,long size)
00151 {
00152 unsigned long * from_page_table;
00153 unsigned long * to_page_table;
00154 un ......
smartd是一个守护进程(一个帮助程序),它能监视拥有自我监视,分析和汇报技术(Self-Monitoring,
Analysis, and Reporting Technology - SMART)的硬盘。
SMART系统使得硬盘能监视并汇报自己的运行状况。它的一个重要特性是能够预测失败,使得系统管理员
能避免数据丢失。
smartd由kernel-utils包缺省安装。用命令 r ......