易截截图软件、单文件、免安装、纯绿色、仅160KB

linux tasklet

http://blog.chinaunix.net/u/24474/showart_227121.html
驱动程序使用tasklet机制
转自:http://blog.chinaunix.net/u/15169/showart.php?id=82989

动程序在初始化时,通过函数task_init建立一个tasklet,然后调用函数tasklet_schedule将这个tasklet放在
tasklet_vec链表的头部,并唤醒后台线程ksoftirqd。当后台线程ksoftirqd运行调用__do_softirq时,会执行在中断
向量表softirq_vec里中断号TASKLET_SOFTIRQ对应的tasklet_action函数,然后tasklet_action遍历
tasklet_vec链表,调用每个tasklet的函数完成软中断操作。
 
下面对函数tasklet_init和tasklet_schedule分析:
   函数tasklet_init初始化一个tasklet,其参数t是tasklet_struct结构描述的tasklet,参数(*func)是软中断响应函数。
void tasklet_init(struct tasklet_struct *t,
    void (*func)(unsigned long), unsigned long data)
{
 t->next = NULL;
 t->state = 0;
 atomic_set(&t->count, 0);
 t->func = func;
 t->data = data;
}
驱动程序调用函数tasklet_schedule来运行tasklet。
static inline void tasklet_schedule(struct tasklet_struct *t)
{
 if (!test_and_set_bit(TASKLET_STATE_SCHED, &t->state))
  __tasklet_schedule(t);
}
函数__tasklet_schedule得到当前CPU的tasklet_vec链表,并执行TASKLET_SOFTIRQ软中断。
void fastcall __tasklet_schedule(struct tasklet_struct *t)
{
 unsigned long flags;
 local_irq_save(flags);
 t->next = __get_cpu_var(tasklet_vec).list;
 __get_cpu_var(tasklet_vec).list = t;
 raise_softirq_irqoff(TASKLET_SOFTIRQ);
 local_irq_restore(flags);
}
函数raise_softirq_irqoff设置软中断nr为挂起状态,并在没有中断时唤醒线程ksoftirqd。函数raise_softirq_irqoff必须在关中断情况下运行。
inline fastcall void raise_softirq_irqoff(unsigned int nr)
{
 __raise_softirq_irqoff(nr);
 /*
  * If we're in an interrupt or softirq, we're done
  * (this also catches softirq-disabled code). We will
  * actually run the softirq once we return from
  * the irq or softirq.
  *
  *


相关文档:

linux ip命令

ip 是个命令, ip 命令的功能很多!基本上它整合了 ifconfig 与 route 这两个命令,不过ip 的功能更强大! 如果您有兴趣的话,请自行 vi /sbin/ifup 就知道整个 ifup 就是利用 ip 这个命令来实现的。下面介绍一下使用方法
[root@linux ~]# ip [option] [动作] [命令]
参数:
option :设定的参数,主要有:
   ......

linux启动过程

linux启动流程:
系统预处理程序->GRUB  (此阶段可以理解为bootloader阶段)
->kernel   (此阶段为kernel)
->initrd->init启动->inittab->rc.sysinit->functions(PATH)->modules->rcX.d(读配置文件)
1.->字符模式->tty->bash
2.->图形模式->进入X Window-> ......

Linux中正确处理errno

errno变量(需include errno.h)会被赋一个整数值,不同的值表示不同的含义,
可以通过查看该值推测出错的原因。但是errno是一个数字,代表的具体含义
还要到errno.h中去阅读宏定义。有下面几种方法可以方便的得到错误信息
(一)
#include <stdio.h>
void perror(const char *s)
perror()用来将上一个函数发生错误的 ......

linux 递归查找文件内容

递归查找文件内容:
grep   -n   -ri   "slewing"   ./
在当前目下递归查找所有的文件
       -i, --ignore-case
              Ignore  case  distinctions  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号