<?xml version="1.0" encoding="gbk"?>
<rss version="2.0">
  <channel>
    <title>曲径通幽论坛 - Examples</title>
    <link>http://www.groad.net/bbs/forum.php?mod=forumdisplay&amp;fid=78</link>
    <description>Latest 20 threads of Examples</description>
    <copyright>Copyright(C) 曲径通幽论坛</copyright>
    <generator>Discuz! Board by Comsenz Inc.</generator>
    <lastBuildDate>Thu, 09 Apr 2026 22:01:32 +0000</lastBuildDate>
    <ttl>60</ttl>
    <image>
      <url>http://www.groad.net/bbs/static/image/common/logo_88_31.gif</url>
      <title>曲径通幽论坛</title>
      <link>http://www.groad.net/bbs/</link>
    </image>
    <item>
      <title>简单休眠</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=3202</link>
      <description><![CDATA[模块代码来自 LDD3。该实例实现了一个简单的休眠。休眠的原因是没有资源可读，当有数据写向设备时睡眠的读进程又会被唤醒。


代码如下：
[mw_shl_code=cpp,true]#include 
#include 


#include   /* current and everything */
#include  /* printk() */
#include     ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 07 Mar 2011 10:12:42 +0000</pubDate>
    </item>
    <item>
      <title>定时器简单应用</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=3132</link>
      <description><![CDATA[定时器一个相关的数据结构(内核版本：Debian5@2.6.26)：

其中常用到的几个量为：
expires --- 超时时间
function --- 超时后执行的函数
data --- 传入 function 函数的变量。


定时器应用简单实例：

Makefile 文件：




加载后通过 demsg 可以看到输出(3秒后)：]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 18 Feb 2011 12:54:00 +0000</pubDate>
    </item>
    <item>
      <title>具有 seq_file 接口的 scull</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=2783</link>
      <description><![CDATA[将 http://www.groad.net/bbs/read.php?tid-2779.html 里的 create_proc_read_entry() 创建 /proc 文件的方法去掉，只添加 seq_file 接口方法。

代码：

Makefile 文件，scull.h 文件，mknode.sh 脚本同 http://www.groad.net/bbs/read.php?tid-2774.html
测试输出：

 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Wed, 29 Sep 2010 16:37:41 +0000</pubDate>
    </item>
    <item>
      <title>具有老式 /proc 文件创建方法的 scull</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=2779</link>
      <description><![CDATA[主代码仍然按照 http://www.groad.net/bbs/read.php?tid-2774.html

代码里主要添加了老式创建 /proc 文件的方法，即使用 create_proc_read_entry 函数。

代码：

Makefile 文件，scull.h 文件，mknode.sh 脚本同 http://www.groad.net/bbs/read.php?tid-2774.html

测 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 27 Sep 2010 15:24:08 +0000</pubDate>
    </item>
    <item>
      <title>scull 最简可运行注释版</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=2774</link>
      <description><![CDATA[看了 LDD 的 scull 代码，发现里面的代码超出第一章的范围，现将适合第一章学习的代码抽取出来，使之可运行，并加上一些详细的注释和做了一点细微的修改。
主程序 scull.c 代码：

头文件 scull.h 代码：

Makefile 文件：

卸载与插入模块脚本文件：

测试：]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 24 Sep 2010 05:39:19 +0000</pubDate>
    </item>
    <item>
      <title>输入输出复用实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1353</link>
      <description><![CDATA[使用打印机端口来测试 poll()函数处理输入输出的复用.
测试用的应用程序代码:
 
说明:
(1)&#160; 先用 write() 开启 LED , 然后进程再使用 poll() 进入睡眠状态,直到有输入数据.
(2)&#160; 没有发生数据的输入,且超时 1s ,进程就会被唤醒,从 poll() 函数种脱出, 接着控 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 09 Nov 2009 12:02:46 +0000</pubDate>
    </item>
    <item>
      <title>等待队列简单实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1337</link>
      <description><![CDATA[这个实例基本上和 http://www.groad.net/bbs/read.php?tid-1294.html中的中断实例一样，去被在于当调用请求 read() 时，因为没有中断发生(没有可读数据)，调用进程会进入睡眠。

驱动程序测试代码：
 

应用程序测试代码：
 
说明：
在驱动程序中，当被应用程序调用 rea ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Tue, 03 Nov 2009 16:05:45 +0000</pubDate>
    </item>
    <item>
      <title>中断应用简单实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1294</link>
      <description><![CDATA[测试程序使用打印机的并口中断特性。在打印机端口的信号中存在 ACK ，此信号表示打印机已经顺利的接受了传送的数据。当计算机向打印机传送数据时，为了确认数据是否正常传送，就需要检查 ACK信号，该信号连接在打印机端口的第 10脚上。与其他引脚不同，该 pin上的信号会 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 23 Oct 2009 09:43:54 +0000</pubDate>
    </item>
    <item>
      <title>内核定时器简单实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1239</link>
      <description><![CDATA[使用内核定时器控制打印机端口上的 LED 。程序代码如下：
 
说明：
在 kerneltimer_init() 函数中：
ptrmng 指向地址上分配了 KERNEL_TIMER_MANAGER 结构体内存空间。
ptrmng-&gt;led = 0 表示一开始 LED 设置为关闭状态。
最后调用 kerneltimer_registertimer() 函数，此 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Fri, 09 Oct 2009 08:22:40 +0000</pubDate>
    </item>
    <item>
      <title>ioctl() 函数输入输出应用实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1216</link>
      <description><![CDATA[实验内容：
分别在 PC 并口的 13 脚和 25 脚引出两条引线，LED 灯长脚(+)接 PC 并口第 2 脚，短脚(-)接 PC 并口 18 脚 。当加载驱动程序后，启动测试应用程序，一开始会启动开启 LED 然后弹出等待输入信息并等待输入。这时接触两根金属引脚，1s 后 LED 关闭，然后再弹出 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Sat, 26 Sep 2009 18:24:48 +0000</pubDate>
    </item>
    <item>
      <title>次设备号文件处理实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1207</link>
      <description><![CDATA[驱动程序代码：
 

Makefile 文件：
 

测试应用程序：]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Thu, 24 Sep 2009 18:39:17 +0000</pubDate>
    </item>
    <item>
      <title>并口读写测试实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1203</link>
      <description><![CDATA[驱动程序 (2.6 kernel) ：
 

Makefile 文件：
 

测试用应用程序：
 

创建设备文件：
mknod&#160; /dev/rdwrdev&#160; c 240&#160; 0

编译驱动模块：
make

加载模块：
insmod&#160; rdwrdev.ko

[hr]说明：
在并口上的 25 脚和 13 脚分别引出两根引线，25 脚接地，1 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Wed, 23 Sep 2009 04:58:43 +0000</pubDate>
    </item>
    <item>
      <title>虚拟字符设备实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1116</link>
      <description><![CDATA[代码(代码来自《驱动开发详解》,为了测试，小有修改)：
 

编译成功后，使用 insmod 命令把模块加载到内核中，通过 lsmod 命令可以看到模块已经被成功加载：


再通过 cat 命令查看 /proc/devices 文件，发现多出了主设备号为 240 的字符设备：


现在通过 mknod 命令创 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Tue, 01 Sep 2009 08:47:28 +0000</pubDate>
    </item>
    <item>
      <title>动态内存使用实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1112</link>
      <description><![CDATA[代码：
 
输出：

在用 rmmod 命令注销掉模块后，在 memtest_exit 中的打印信息(Module Memory Test End)才会输出来。]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 31 Aug 2009 18:11:36 +0000</pubDate>
    </item>
    <item>
      <title>简单字符设备创建实例</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1089</link>
      <description><![CDATA[下面包括两个程序代码，一个是 call_app.c 构成的应用程序；一个是 call_dev.c 构成的字符设备驱动程序。

call_dev.c 完整代码如下(程序中使用了老式字符设备注册与注销函数)：
 

call_app.c 用户程序代码：
 

Makefile 文件：
 
[/pre]
[hr]make 过程：

因为在 cal ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Thu, 27 Aug 2009 09:11:36 +0000</pubDate>
    </item>
    <item>
      <title>/dev/lp0 读取并口输入状态</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1024</link>
      <description><![CDATA[实验目标：
利用 /dev/lp0 设备文件，读取打印口输入状态。

实验步骤：
1、在并口的第 13 脚上引出一线，在第 25 脚上引出另一线，第 2 脚接 LED 的正极，第 18 脚接 LED 的负极。

2、测试代码：
 

3、说明：
/dev/lp0 设备文件可以控制打印机端口。该设备文件没有直 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 10 Aug 2009 11:09:05 +0000</pubDate>
    </item>
    <item>
      <title>/dev/port 设备文件简单测试并口</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1023</link>
      <description><![CDATA[实验目标：
在 PC 机上的并口延长线上接一 LED ，通过使用 /dev/port 设备文件控制 LED 闪动。

实验步骤：

1、在 BIOS 里把并口模式改为 SPP 

SPP ( Sequenced Packed Protocol ，序列分组协议 ) 是标准模式，它与 EPP 和 ECP 不同，是早期定义的规范 ( Centronic )  ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Mon, 10 Aug 2009 09:01:31 +0000</pubDate>
    </item>
    <item>
      <title>&quot;hello world&quot; 简单内核模块</title>
      <link>http://www.groad.net/bbs/forum.php?mod=viewthread&amp;tid=1006</link>
      <description><![CDATA[程序代码：
 
编译方法( 只针对 2.6 内核 )：
编写 Makefile 文件，Makefile 文件内容很简单，只有一行：

执行命令：



说明：
经过以上简单几步后，即生成了一个简单的模块。这个模块在加载之后，属于内核空间，是内核空间的一部分，而不是用户空间。
在 2.6 内核版 ...]]></description>
      <category>Examples</category>
      <author>beyes</author>
      <pubDate>Thu, 06 Aug 2009 17:27:01 +0000</pubDate>
    </item>
  </channel>
</rss>