2017年10月25日

进程优先级和调度

摘要: nice的值范围-20~19(数字越小,优先级越高)//获取和修改优先级#include//which参数确定who参数如何被解释,该值取值如下PRIO_PROCESS 操作进程id为who的进程,如果who为0,使用调用者的进程idPRIO_PGRP 操作进程组id为wh... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(848) 评论(0) 推荐(0)

会话,进程组,作业控制

摘要: #include//获取一个进程的进程组pid_t getpgrp(void);//将进程id为pid的进程的进程组id修改为pgid//如果将pid设置为0,那么调用进程的进程组id就会改变,如果将pgid的设为0,那么id为pid的进程的进程组id会被设置为pid的值int se... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(123) 评论(0) 推荐(0)

线程

摘要: 在linux平台上,在编译调用了PthreadsAPI的程序时,需要设置 cc -pthread(等价于-lpthread)的编译选项#includeint pthread_create(pthread_t *thread,const pthread_attr_t *attr,voi... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(138) 评论(0) 推荐(0)

详述进程创建和程序执行

摘要: #include//一般会将相应命令至于系统启动脚本中,在系统每次重启时开启进程记账功能,其中acctfile中指定一个常规文件的路径名,记账文件通常的路径名是/var/log/pacct或/usr/account/pacct,如果想关闭进程记账功能,指定acctfile为NULLi... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(140) 评论(0) 推荐(0)

进程的创建

摘要: #includepid_t fork(void);创建一新进程,如果成功创建子进程,总是返回0,子进程的数据不会影响父进程的数据,不过文件相关属性会有影响,例如子进程中修改文件偏移量,父进程中的也跟着变(父进程中用wait或者sleep函数使得子进程得以运行)#includepid_... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(110) 评论(0) 推荐(0)

定时器与休眠

摘要: #includeint setitimer(int which,const struct itimerval *new_value,struct itimerval *old_value); //创建一个间隔式定时器(interval timer),在未来某个时间点到期,并于此后每隔... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(400) 评论(0) 推荐(0)

信号高级特性

摘要: #includeint sigqueue(pid_t pid,int sig,const union sigval value); //将sig指定的实时信号发送给有pid指定的进程union sigval{int sival_int;void *sival_ptr;};//联合... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(107) 评论(0) 推荐(0)

信号的基本概念

摘要: SIGABRT 当进程调用abort函数时,系统向该进程发送该信号,默认情况下,该信号会杀死进程,并产生核心转储文件SIGALRM 调用alarm()或者settimer()设置的实时定时器一旦到期,内核将产生该信号SIGBUS 产生该信号,说明某种内存访问... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(195) 评论(0) 推荐(0)

监控文件事件inotify

摘要: #includeint inotify_init(void);//创建一个新的inotify实例,成功会返回一个文件描述符fdint inotifyk_add_watch(int fd,const char *pathname,uint32_t mask);//追加新的的监控项,也可... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(143) 评论(0) 推荐(0)

目录与链接

摘要: 创建和移除(硬)链接#includeint link(const char *oldpath,const char *newpath)//如果oldpath是符号链接,该函数不会对其解引用int unlink(const char *pathname)//也不会解引用//更改文件名i... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(333) 评论(0) 推荐(0)

文件访问控制列表facl

摘要: [root@bogon code]# getfacl a.c //获取文件a.c的文件访问控制列表# file: a.c# owner: root# group: rootuser::rw-group::r--other::r--[root@bogon code]# getfacl... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(379) 评论(0) 推荐(0)

文件扩展属性

摘要: 扩展属性EA,既以名称-值对形式将任意元数据与文件i 节点关联起来的技术 在shell中操作[root@bogon code]# setfattr -n user.x -v "this is first" linux[root@bogon code]# setfattr -n use... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(458) 评论(0) 推荐(0)

文件属性相关(一)

摘要: 获取文件信息:#includeint stat(const char *pathname,struct stat *statbuf);int lstat(const char *pathname,struct stat *statbuf);//用于符号链接,指的是符号本身int fs... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(196) 评论(0) 推荐(0)

系统编程概念(文件系统mount等函数的使用)

摘要: 挂载文件系统#includeint mount(const char *source,const char *target,const char *fstype,unsigned long mountflags,const void *data)其中mountflags的值可为: M... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(734) 评论(0) 推荐(0)

文件I/0缓冲

摘要: 设置stdio流缓冲模式#includeint setvbuf(FILE *stream,char *buf,int mode,size_t size) int setbuf(FILE *stream,char *buf)//该函数不返回函数结果int setbuffer(FI... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(104) 评论(0) 推荐(0)

系统和进程相关信息

摘要: 查看进程号为1的进程信息[root@bogon code]# cat /proc/1/status //proc目录下的数字就是进程号]Name: systemdState: S (sleeping)Tgid: 1Ngid: 0Pid: 1PPid: 0Tr... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(125) 评论(0) 推荐(0)

系统限制和选项limit(一)

摘要: 从shell中获取系统限制和选项 终端输入getconf value [pathname][root@bogon code]# getconf ARG_MAX 2097152[root@bogon code]# getconf NAME_MAX /root //涉及路径名的在后... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(498) 评论(0) 推荐(0)

常用C语言time时间函数

摘要: 常见的时间函数有time( )、ctime( )、gmtime( )、localtime( )、mktime( )、asctime( )、difftime( )、gettimeofday( )、settimeofday( ) 其中,gmtime和localtime函数差不多,只是lo... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(2009) 评论(0) 推荐(0)

setjmp与longjmp非局部跳转函数的使用

摘要: [root@bogon code]# cat c.c#include#includestatic jmp_buf env;//定义全局变量envvoid job(){ longjmp(env,2);//会返回到setjmp(env)处,且返回值为2}void work(int ... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(391) 评论(0) 推荐(0)

环境列表

摘要: 终端添加环境变量BP=/root/code //环境名一般使用大写export BPecho $BP //显示/root/code终端输入printenv 打印当前环境列表 char getenv(cont char *name)获取某个环境变量name的值,成功返回name,失... 阅读全文

posted @ 2017-10-25 18:06 标配的小号 阅读(114) 评论(0) 推荐(0)

导航