随笔分类 -  linux_program

linux program
摘要:进程间通信: # 管道( pipe ):管道是一种半双工的通信方式,数据只能单向流动,而且只能在具有亲缘关系的进程间使用。进程的亲缘关系通常是指父子进程关系。# 命名管道 (named pipe/FIFO) : 命名管道也是半双工的通信方式,但是它允许无亲缘关系进程间的通信。# 信号量( semop 阅读全文
posted @ 2017-04-07 22:53 soul.stone 阅读(1642) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include #include #include #include /* int shm_open(const char *name, int oflag, mode_t mode); //创建或打开一个共享内存,成功返回一个整数的文件描述符,错误返回-1。 name : 共享内... 阅读全文
posted @ 2017-04-07 22:32 soul.stone 阅读(302) 评论(0) 推荐(0)
摘要:参考文档:http://blog.csdn.net/evsqiezi/article/details/8061176头文件:#include<semaphore.h> int sem_init __P ((sem_t *__sem, int __pshared, unsigned int __val 阅读全文
posted @ 2017-04-07 22:27 soul.stone 阅读(1223) 评论(0) 推荐(0)
摘要:int pthread_create((pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)若线程创建成功,则返回0。若线程创建失败,则返回出错编号,并且*thread中的内容是未定义的 阅读全文
posted @ 2017-04-07 22:16 soul.stone 阅读(612) 评论(0) 推荐(0)
摘要:源代码: 测试代码: 阅读全文
posted @ 2017-02-11 23:34 soul.stone 阅读(378) 评论(0) 推荐(0)
摘要:源代码: makefile: 测试代码: 阅读全文
posted @ 2017-02-09 23:17 soul.stone 阅读(299) 评论(0) 推荐(0)
摘要:源代码: makefile: 测试代码: 阅读全文
posted @ 2017-02-09 23:15 soul.stone 阅读(276) 评论(0) 推荐(0)
摘要:1、DSB、ISB writel(data, addr); \ __asm__ __volatile__("DSB"); \ 2、cache flush flush_cache_all(); outer_flush_all(); 3、dma_map_single 阅读全文
posted @ 2017-02-07 19:25 soul.stone 阅读(246) 评论(0) 推荐(0)
摘要:1、ioremap_nocache 阅读全文
posted @ 2017-02-07 19:14 soul.stone 阅读(181) 评论(0) 推荐(0)
摘要:http://blog.csdn.net/tommy_wxie/article/details/8194276 1. 序曲 在用户态,读写文件可以通过read和write这两个系统调用来完成(C库函数实际上是对系统调用的封装)。 但是,在内核态没有这样的系统调用,我们又该如何读写文件呢? 阅读Lin 阅读全文
posted @ 2017-02-05 15:11 soul.stone 阅读(14600) 评论(1) 推荐(2)
摘要:http://blog.chinaunix.net/uid-17188120-id-4073497.html 1,启动inittab第一步:启动内核第二步:执行init (配置文件/etc/inittab)第三步:启动相应的脚本,执行inittab脚本,并且执行其他脚本/etc/init.d rc. 阅读全文
posted @ 2017-01-24 11:29 soul.stone 阅读(480) 评论(0) 推荐(0)
摘要:需求在《linux进程调度浅析》一文中提到,在SMP(对称多处理器)环境下,每个CPU对应一个run_queue(可执行队列)。如果一个进程处于TASK_RUNNING状态(可执行状态),则它会被加入到其中一个run_queue(且同一时刻仅会被加入到一个run_queue),以便让调度程序安排它在 阅读全文
posted @ 2016-12-10 22:28 soul.stone 阅读(3784) 评论(0) 推荐(1)
摘要:1,为什么需要进程调度 首先,我们需要明确一点:进程调度是对TASK_RUNNING状态的进程进行调度(参见《linux进程状态浅析》)。如果进程不可执行(正在睡眠或其他),那么它跟进程调度没多大关系。所以,如果你的系统负载非常低,盼星星盼月亮才出现一个可执行状态的进程。那么进程调度也就不会太重要。 阅读全文
posted @ 2016-12-10 22:20 soul.stone 阅读(376) 评论(0) 推荐(0)
摘要:在知乎上,有个人问了这样的一个问题——为什么vfork的子进程里用return,整个程序会挂掉,而且exit()不会?并给出了如下的代码,下面的代码一运行就挂掉了,但如果把子进程的return改成exit(0)就没事。 我受邀后本来不想回答这个问题的,因为这个问题明显就是RTFM的事,后来,发现这个 阅读全文
posted @ 2016-12-10 22:09 soul.stone 阅读(366) 评论(0) 推荐(0)
摘要:写一个模块测试proc文件的读写: 1 #include linux/module.h 2 #include linux/kernel.h 3 #include linux/proc_fs.h 4 #include linux/sched.h 5 #include asm/uaccess.h 6 7 阅读全文
posted @ 2016-12-04 19:51 soul.stone 阅读(217) 评论(0) 推荐(0)
摘要:#include <unistd.h>int execl(const char *path, const char *arg, ...);int execlp(const char *file, const char *arg, ...);int execle(const char *path, c 阅读全文
posted @ 2016-12-04 17:10 soul.stone 阅读(459) 评论(0) 推荐(0)
摘要:1、jiffies HZ=100,jiffies=1 means 10ms。 2,延时 unsigned long timeout = jiffies + (3*HZ); while (hwgroup->busy) { if (time_after(jiffies, timeout)) { retu 阅读全文
posted @ 2016-12-04 16:19 soul.stone 阅读(622) 评论(0) 推荐(0)
摘要:1,进程绑定 #include <sched.h> cpu_set_t set;void CPU_ZERO(cpu_set_t *set);void CPU_SET(int cpu, cpu_set_t *set);void CPU_CLR(int cpu, cpu_set_t *set);int 阅读全文
posted @ 2016-12-04 14:01 soul.stone 阅读(435) 评论(0) 推荐(0)