2016年3月23日

Understanding Unix/Linux Programming-用户程序play_again4.c

摘要: 1 /* play_again4.c 2 * When no is input , restore the tty settings 3 */ 4 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 12 #define ASK "D... 阅读全文

posted @ 2016-03-23 09:39 H.D 阅读(280) 评论(0) 推荐(0) 编辑

2016年3月22日

Understanding Unix/Linux Programming-信号与play_again4.c的准备知识

摘要: Ctrl-C终止当前运行的程序,这个中断由一个称为信号的内核机制产生。信号是一个简单而重要的概念,下面将探讨信号的基本概念。 终端驱动程序在这里起到了相应的作用: 当然未必一定是Ctrl-C作为中断的控制字符,这是可以更改驱动设置的。 信号是由单个词组成的消息。绿灯、停止标牌、裁判手势等都是信号,而 阅读全文

posted @ 2016-03-22 09:07 H.D 阅读(326) 评论(0) 推荐(0) 编辑

2016年3月18日

Understanding Unix/Linux Programming-用户程序:play_again3

摘要: 这里使用到了非阻塞输入: 怎么解释非阻塞输入与阻塞输入? 书上解释: 当调用getchar或者read从文件描述符读取输入时,这些调用通常会等待输入,这叫做阻塞输入(block input)。在play_again的例子中,对于getchar的调用使得程序一直等待用户的输入,知道用户输入一个字符。程 阅读全文

posted @ 2016-03-18 15:28 H.D 阅读(343) 评论(0) 推荐(0) 编辑

Understanding Unix/Linux Programming-用户程序:play_again2

摘要: 1 /* play_again1.c 2 * purpuse: ask if user wants another play 3 * better : instant response without echo 4 * returns: 0 -> yes , 1 -> no 5 */ 6 7 #include 8 #include 9 #include... 阅读全文

posted @ 2016-03-18 14:25 H.D 阅读(184) 评论(0) 推荐(0) 编辑

2016年3月17日

控制系统的带宽与二阶系统的简单定性理解

摘要: 先上自动控制原理上面的定义: 当控制系统的幅频特性下降到比零频率幅值低3dB时,所对应的频率为带宽频率,简称带宽。 系统的带宽反应了系统响应的快速性,也反映了对输入信号的复现能力。带宽大,系统的响应越快咯,但是带宽过宽,那么现实世界中的噪声会引入系统,造成不利影响。 这么说也许过于抽象,不知诸位看客 阅读全文

posted @ 2016-03-17 16:30 H.D 阅读(10221) 评论(1) 推荐(0) 编辑

Understanding Unix/Linux Programming-用户程序:play_again1

摘要: 1 /* play_again1.c 2 * purpuse: ask if user wants another play 3 * better : instant response without echo 4 * returns: 0 -> yes , 1 -> no 5 */ 6 7 #include 8 #include 9 #include... 阅读全文

posted @ 2016-03-17 10:58 H.D 阅读(265) 评论(0) 推荐(0) 编辑

Understanding Unix/Linux Programming-用户程序:play_again0

摘要: 1 /* play_again0.c 2 * purpuse: ask if user wants another play 3 * returns: 0 -> yes , 1 -> no 4 */ 5 6 #include 7 #include 8 #include 9 10 #define QUESTION "Do you want anot... 阅读全文

posted @ 2016-03-17 10:57 H.D 阅读(238) 评论(0) 推荐(0) 编辑

Understanding Unix/Linux Programming-终端控制和信号

摘要: 终端驱动程序的模式: 先通过简短的转换程序来深入理解设备驱动程序的细节: 使用tr命令能够达到同样的效果,但是tr的GNU版本具有输入缓冲,以上是一个不带缓冲的具体例子。这个程序中,rotate程序是和终端驱动器交换数据的,而终端驱动器从键盘输入数据并且从屏幕输出数据。 规范模式:缓冲和编辑 使用默 阅读全文

posted @ 2016-03-17 10:17 H.D 阅读(342) 评论(0) 推荐(0) 编辑

2016年3月16日

Understanding Unix/Linux Programming-文件、设备和流

摘要: 每个设备文件都支持系统调用 ioctl: 实际上,任何数据的源或者目的地都被Unix视为文件来处理,基本的系统调用既支持磁盘文件,也适用于设备文件。它们的区别体现在对于连接的操作上。磁盘文件的文件描述符包含对缓冲属性和扩展属性的定义代码;而终端的文件描述符包含编辑、回显、字符转换和其他操作的定义代码 阅读全文

posted @ 2016-03-16 21:19 H.D 阅读(322) 评论(0) 推荐(0) 编辑

Understanding Unix/Linux Programming-stty指令练习

摘要: 先来看一个简单的练习程序: 以上是程序编译后运行的效果啦,可以看到在输入hello之后敲击回车后才运行了该程序,也就是说,在终端中输入的字符实际上是被缓冲的。 另外,回车键本身被识别为换行了,也由该程序识别了,这也与终端的设置有关。 tty驱动程序包含很多对数据的操作: 编写终端驱动程序:关于系统调 阅读全文

posted @ 2016-03-16 11:16 H.D 阅读(227) 评论(0) 推荐(0) 编辑

导航