linux I/O possible

linux I/O possible

在linux环境下编写应用程序的同学,肯定会遇到过程序编译没问题,但是运行时却出现奇奇怪怪的问题的现象。
比如,这次要说到的这个现象,程序运行到读取外设数据的时候,弹出
“I/O possible”,然后程序就退出的现象:

首先

大概猜一下,提示的是什么意思?I O 字面上,基本就能确定,是输入与输出的意思;possible?可能?什么可能呢?输入输出可能?
显然不太对,再猜一下,可能意思就是数据可能来了。

然后

在进行串口或者网络编程的时候,数据的到来时刻是未知的。一般的书籍,对于数据的处理就是两种:轮询或者异步IO。
轮询,即是poll的方式,不停的查询。
异步IO,即是数据来了发信号。

其实,对于两种方式的优劣,并没有很明显的区分。只是看具体的程序设计。这时候,发现周围的人,对异步IO比较狂热,可能是受到了,轮询是纯粹浪费时间的思想的侵蚀。

然后呢,说到轮询,在linux下编程,很多人自然用到了select ,pselect函数。

说到这里,想起来曾经看到同行说到的一句话,能用轮询的就不要用异步。

最后

说了这么多废话,其实出现问题的原因,在于你的函数的初始化,误用了fcntl。不管你是否真正理解了函数的作用,对fnctl这个函数请不要乱用!

fcntl

函数用法:

fcntl(fd, F_SETOWN, getpid());

函数的实现,其实对应了SIGIO信号。即当有数据到来时,主动给所注册的进程发送SIGIO信号,在linux环境下,很多信号的默认行为就是终止进程,SIGIO也不例外。

为什么会这样

用到了fcntl,却没有注册信号处理函数。当然,信号到来时,进程留给你的只有一行字符串“I/O possible”

怎么办

a.要么删除fcntl ,F_SETOWN的代码行,继续用select调用
b.保留F_SETOWN的调用,添加SIGIO的信号处理函数。主循环即可以用sigsuspend调用来等待信号的到来了。

参考资料

1.http://davmac.org/davpage/linux/async-io.html
2.http://www.linuxquestions.org/questions/programming-9/i-o-possible-message-with-select-892241/

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MSR Identity Toolbox: A Matlab Toolbox for Speaker Recognition Research Version 1.0 Seyed Omid Sadjadi, Malcolm Slaney, and Larry Heck Microsoft Research, Conversational Systems Research Center (CSRC) [email protected], {mslaney,larry.heck}@microsoft.com This report serves as a user manual for the tools available in the Microsoft Research (MSR) Identity Toolbox. This toolbox contains a collection of Matlab tools and routines that can be used for research and development in speaker recognition. It provides researchers with a test bed for developing new front-end and back-end techniques, allowing replicable evaluation of new advancements. It will also help newcomers in the field by lowering the “barrier to entry”, enabling them to quickly build baseline systems for their experiments. Although the focus of this toolbox is on speaker recognition, it can also be used for other speech related applications such as language, dialect and accent identification. In recent years, the design of robust and effective speaker recognition algorithms has attracted significant research effort from academic and commercial institutions. Speaker recognition has evolved substantially over the past 40 years; from discrete vector quantization (VQ) based systems to adapted Gaussian mixture model (GMM) solutions, and more recently to factor analysis based Eigenvoice (i-vector) frameworks. The Identity Toolbox provides tools that implement both the conventional GMM-UBM and state-of-the-art i-vector based speaker recognition strategies. A speaker recognition system includes two primary components: a front-end and a back-end. The front-end transforms acoustic waveforms into more compact and less redundant representations called acoustic features. Cepstral features are most often used for speaker recognition. It is practical to only retain the high signal-to-noise ratio (SNR) regions of the waveform, therefore there is also a need for a speech activity detector (SAD) in the fr
1、查看SSH客户端版本 有的时候需要确认一下SSH客户端及其相应的版本号。使用ssh -V命令可以得到版本号。需要注意的是,Linux一般自带的是OpenSSH: 下面的例子即表明该系统正在使用OpenSSH: $ ssh -V OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003 下面的例子表明该系统正在使用SSH2: $ ssh -V ssh: SSH Secure Shell 3.2.9.1 (non-commercial version) on i686-pc-linux-gnu 2、用SSH登录到远程主机 当你第一次使用ssh登录远程主机时,会出现没有找到主机密钥的提示信息。输入"yes"后,系统会将远程主机的密钥加入到你的主目录下的 .ssh/hostkeys下,这样你就可以继续操作了。示例如下: 1 2 3 4 5 6 7 8 localhost$ ssh -l jsmith remotehost.example.com Host key not found from database. Key fingerprint: xabie-dezbc-manud-bartd-satsy-limit-nexiu-jambl-title-jarde-tuxum You can get a public key‘s fingerprint by running % ssh-keygen -F publickey.pub on the keyfile. Are you sure you want to continue connecting (yes/no)? Yes Host key saved to /home/jsmith/.ssh2/hostkeys/key_22_remotehost.example.com.pub host key for remotehost.example.com, accepted by jsmith Mon May 26 2008 16:06:50 -0700 [email protected] password: remotehost.example.com$ 因为远程主机的密钥已经加入到ssh客户端的已知主机列表中,当你第二次登陆远程主机时,只需要你输入远程主机的登录密码即可。 1 2 3 localhost$ ssh -l jsmith remotehost.example.com [email protected] password: remotehost.example.com$ 由于各种原因,可能在你第一次登陆远程主机后,该主机的密钥发生改变,你将会看到一些警告信息。出现这种情况,可能有两个原因: o 系统管理员在远程主机上升级或者重新安装了SSH服务器 o 有人在进行一些恶意行为,等等。 在你输入“yes”之前呢,最佳的选择或许是联系你的系统管理员来分析为什么会出现主机验证码改变的信息,核对主机验证码是否正确。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 localhost$ ssh -l jsmith remotehost.example.com @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the- middle attack)! It is also possible that the host key has just been changed. Please contact your system administrator. Add correct host key to ―/home/jsmith/.ssh2/hostkeys/key_22_remotehost.example.com.pub‖ to get rid of this message. Received server key's fingerprint: xabie-dezbc-manud-bartd-satsy-limit-nexiu-jambl-title-arde-tuxum You can get a publ

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值