引用 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 ......
1、检测
安装之前先检测是否这些软件包已安装,方法如下:[root@localhost
root]#rpm -q telnet或[root@localhost root]#rpm -q telnet-client
[root@localhost root]#rpm -q
telnet-server
如果没有检测到软件包,需要进行安装,据说red hat Linux
9默认已安装了telnet软件包,不知道为什么我的没有,还好没关系,只是在Linux上安装telnet的服务器,就只安装telnet-
server软件包
。网上搜索一下,不难找的。当然,前提是你的Linux能上网。
2、安装软件包
[root@localhost root]#rpm -i
telnet-server-0.17-25.i386.rpm
3、开启服务
方法二:编辑 /etc/xinetd.d/telnet
[root@localhost root]# vi
/etc/xinetd.d/telnet
找到 disable = yes 将 yes 改成 no 。
方法三:chkconfig telnet
on //该命令修改了/etc/xinetd.d/telnet的配置,设置disable=no
4、激活服务
telnet-server不作为独立的服务器程序运行,而是受xinetd程序
的控制,启动配置文件为/etc/xinetd.d/telnet,默认xinetd程序并不启动该服务,所以修改了配置文件后要重启xinted
[root@localhost root]# service xinetd
restart
5、测试服务
[root@localhost root]#telnet
......
7.5. Tasklets 机制
上一页
第 7 章 时间, 延时, 和延后工作
下一页
http://lsec.cc.ac.cn/~tengfei/doc/ldd3/index.html
Linux 设备驱动 Edition 3
7.5. Tasklets 机制
另一个有关于定时问题的内核设施是 tasklet 机制. 它大部分用在中断管理(我们将在第 10 章再次见到).
tasklet 类似内核定时器在某些方面. 它们一直在中断时间运行, 它们一直运行在调度它们的同一个 CPU 上, 并且它们接收一个
unsigned long 参数. 不象内核定时器, 但是, 你无法请求在一个指定的时间执行函数. 通过调度一个 tasklet,
你简单地请求它在以后的一个由内核选择的时间执行. 这个行为对于中断处理特别有用, 那里硬件中断必须被尽快处理,
但是大部分的时间管理可以安全地延后到以后的时间. 实际上, 一个 tasket, 就象一个内核定时器,
在一个"软中断"的上下文中执行(以原子模式), 在使能硬件中断时执行异步任务的一个内核机制.
一个 tasklet 存在为一个时间结构, 它必须在使用前被初始化. 初始化能够通过调用一个特定函数或者通过使用某些宏定义声明结构:
#include <linux/interrupt.h>
struct tasklet_struct {
/* .. ......
大致命令如下:
tar xvfj lichuanhua.tar.bz2
tar xvfz lichuanhua.tar.gz
tar xvfz lichuanhua.tgz
tar xvf lichuanhua.tar
unzip lichuanhua.zip
.gz
解压1:gunzip FileName.gz
解压2:gzip -d FileName.gz
压缩:gzip FileName
.tar.gz
解压:tar zxvf FileName.tar.gz
压缩:tar zcvf FileName.tar.gz DirName
---------------------------------------------
.bz2
解压1:bzip2 -d FileName.bz2
解压2:bunzip2 FileName.bz2
压缩: bzip2 -z FileName
.tar.bz2
解压:tar jxvf FileName.tar.bz2
压缩:tar jcvf FileName.tar.bz2 DirName
---------------------------------------------
.bz
解压1:bzip2  ......
http://blog.chinaunix.net/u2/69889/showart_971040.html
Linux中的工作队列
[前记]Linux自从2.6.20之后,工作队列发生了一些变化,目前从网络上搜索的资料一般都是介绍老版本的工作队列,很少见到对新版本的介绍。本文对新老版本都做了简要概述,并分别提供了简单的实作案例。
*******************************************************************************************************************
工作队列
(work
queue)
是
Linux
kernel
中将工作推后执行的一种机制。这种机制和
BH
或
Tasklets
不同之处在于工作队列是把推后的工作交由一个内核线程去执行,因此工作队列的优势就在于它允许重新调度甚至睡眠。
工作队列是
2.6
内核开始引入的机制,在
2.6.20
之后,工作队列的数据结构发生了一些变化,因此本文分成两个部分对
2.6.20
之前和之后的版本分别做介绍。
1
、
2.6.0~2.6.19
数据结构:
struct
work_struct {
unsigned
long pending;
struct
list_head entry;
void
(*func)(void *);
void
*data;
void
*wq_da ......
linux系统中对信号的处理主要是signal 和sigaction函数来完成,pause用来响应任何信号,但不做任何处理。
1。signal函数
该函数用来设置进程在接到信号的动作。可以 man signal查看具体用法,现在对其用法演示,
SIGKILL SIGSTOP是不能被捕捉和忽略的信号。
#include <stdio.h>
#include <signal.h>
void handler_sigint (int signo)
{
printf("recv SIGINT\N");
}
int main()
{
signal(SIGINT,handler_sigint);
while(1)
;
return 0;
}
解释:while为死循环,ctrl+c产生SIGINT信号,而ctrl+\将向进程SIGQUIT 信号,但程序本身没有处理该信号,则使用默认处理方式,退出程序。也可以kill;
......