http://hi.baidu.com/j_fo/blog/item/55f4014f1a226937aec3ab01.html
Linux Kernel Thread 的讨论
2007-05-14 11:45
kernel thread
Gearheads Written by Sreekrishnan Venkateswaran
Thursday, 15 September 2005
Threads are programming abstractions used in concurrent processing. A kernel thread is a way to implement background tasks
inside the kernel. A background task can be busy handling asynchronous
events or can be asleep, waiting for an event to occur. Kernel threads
are similar to user processes, except that they live in kernel space
and have access to kernel functions and data structures. Like user
processes, kernel threads appear to monopolize the processor because of
preemptive scheduling.
In
this month’s “Gearheads,” let’s discuss kernel threads and develop an
example that also demonstrates such as process states, wait queues, and
user-mode helpers.
Built-in Kernel Threads
To
see the kernel threads (also called kernel proce ......
http://www.cublog.cn/u/2108/showart_223258.html
Linux内核数据包处理流程-数据包接收
与其说这篇文章分析了网卡驱动中中数据包的接收,还不如说是以e100为例,对网卡驱动编写的一个说明。
当然,对数据包的接收说的很清楚。
转载
数据包的接收
作者:kendo
Kernel:2.6.12
一、从网卡说起
这并非是一个网卡驱动分析的专门文档,只是对网卡处理数据包的流程进行一个重点的分析。这里以Intel的e100驱动为例进行分析。
大多数网卡都是一个PCI设备,PCI设备都包含了一个标准的配置寄存器,寄存器中,包含了PCI设备的厂商ID、设备ID等等信息,驱动
程序使用来描述这些寄存器的标识符。如下:
CODE:
struct pci_device_id {
__u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
__u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
__u32 class, class_mask; /* (class,subclass,prog-if) triplet */
......
第一步,我们在Linux系统下,修改/etc/X11/xdm/Xaccess文件,找到下面的语句:
# * #any host can get a login window
去掉最前面的#号,成为
* #any host can get a login window
第二步,我们修改/etc/X11/gdm/gdm.conf文件,找到下面的语句:
[xdmcp]
Enable=false
将其中的Enable=false 改为Enable=true 或 Enable=1。
同时我们要确保存在下面的语句,因为177端口是我们要配置的xdmcp服务的监听端口,我们在后面配置xmanager将看。
Port=177
第三步,我们要修改/etc/inittab文件,将下面的语句
id:3:initdefault
改为如下,如果原来就是id:5:initdefault就不用更改。
同时,找到如下图文字所在的地方
x:5:respawn:/etc/X11/prefdm -nodaemon
将它修改为x:5:respawn:/usr/bin/gdm
第四步,我们修改/etc/X11/xdm/xdm-config的最后一行,在displayManager.requestPort:0前面加上一个!号,结果如下:
!DisplayManager.requestPort: 0
第五步,我们修改确保/etc/X11/xdm/Xservers的属性为444,/etc/X11/xdm/Xset ......
查看系统中开放的端口,关闭不需要的端口和程序,如下例中操作流程:
1. 查看对外开启的端口:
[root@mail ~]# nmap 127.0.0.1 #注:此处应该换作公网ip
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-04-20 11:06 CST
Interesting ports on 127.0.0.1
Not shown: 1668 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
1010/tcp open unknown
2. 对不明端口进行查访
[root@mail ~]# netstat -anlp | grep 1010
tcp 0 0 0.0.0.0:1010 0.0.0.0:* LISTEN 3796/rpc.statd
#
#[root@mail ~]# lsof -p 3796
#
#
[root@mail init.d]# which rpc.statd
/sbin/rpc.statd
[root@mail ~]# rpm -qf /sbin/rpc.statd
nfs-utils-1.0.9-40.el5
[root@mail init.d]# ll /etc/init.d/nfs*
-rwxr-xr-x 1 root root 4668 Jan 21 2009 /etc/in ......
http://hi.baidu.com/styl_007/blog/item/82b833f475036ce67609d7b6.html
中断处理的tasklet(小任务)机制-不过如此
2009-08-10 18:30
中断服务程序一般都是在中断请求关闭的条件下执行的
,
以避免嵌套而使中断控制复杂化。但是,中断是一个随机事件,它随时会到来,如果关中断的时间太长,
CPU
就不能及时响应其他的中断请求,从而造成中断的丢失。因此,Linux内核的目标就是尽可能快的处理完中断请求,尽其所能把更多的处理向后推迟。例如,假设一个数据块已经达到了网线,当中断控制器接受到这个中断请求信号时,
Linux
内核只是简单地标志数据到来了,然后让处理器恢复到它以前运行的状态,其余的处理稍后再进行(如把数据移入一个缓冲区,接受数据的进程就可以在缓冲区找到数据)。因此,内核把中断处理分为两部分:上半部(
tophalf
)和下半部(
bottomhalf
),上半部(就是中断服务程序)内核立即执行,而下半部(就是一些内核函数)留着稍后处理,
首先,一个快速的“上半部”来处理硬件发出的请求,它必须在一个新的中断产生之前终止。通常,除了在设备和一些内存缓冲区(如果你的设备用到了
DMA
,就不止这些)之间移动或传送数据, ......
引用 2 楼 cokeliu 的回复:
谢谢! 请问是否每调用一次tasklet_schedule(B task); B task任务被加到链表上只会被执行一次?
是的,只被加一次
第一次tasklet_schedule(B task)给他一个状态TASK_STATE_SCHED
作标记,以后的tasklet_schedule(B task)会检查这个标记
http://os.inf.tu-dresden.de/l4env/doc/html/dde_linux/group__mod__softirq.html
Deferred Activities
[Linux DDE Common
]
This module emulates deferred activities
at interrupt level inside the Linux kernel.
More...
Softirqs
This is from include/linux/interrupt.h
Softirqs are multithreaded, not serialized BH-like activities. Several
softirqs may run on several CPUs simultaneously - no matter if they are
of the same type.
Properties:
If raise_softirq()
is called, then softirq is guarenteed to be executed on this CPU.
On schedule()
do_softirq() is called if any softirq is active on this CPU.
Softirqs are not serialized in any way.
Linux (2.4.20) has only 4 softirqs:
HI_SOFTIRQ
NET_TX_SOFTIRQ
and NET_RX_SOFTIRQ
TASKL ......