当前位置: 首页 > news >正文

现货交易十大平台湖南长沙seo教育

现货交易十大平台,湖南长沙seo教育,网站建设应注意哪些事项,做网站要到通信管理局备案1.信号驱动IO框架图 分析: 信号驱动IO是一种异步IO方式。linux预留了一个信号SIGIO用于进行信号驱动IO。进程主程序注册一个SIGIO信号的信号处理函数,当硬件数据准备就绪后会发起一个硬件中断,在中断的处理函数中向当前进程发送一个SIGIO信号…

 1.信号驱动IO框架图

分析:

        信号驱动IO是一种异步IO方式。linux预留了一个信号SIGIO用于进行信号驱动IO。进程主程序注册一个SIGIO信号的信号处理函数,当硬件数据准备就绪后会发起一个硬件中断,在中断的处理函数中向当前进程发送一个SIGIO信号。进程收到SIGIO信号后执行信号处理函数,在信号处理函数中将数据读走即可。

应用层:1.打开设备文件,2注册SIGIO信号处理函数,3回调驱动中的fasync方法,4设置fd对应的驱动程序发送SIGIO信号只发送给当前进程

驱动层:完成异步对象的空间分配和初始化

硬件层:中断处理函数:发送SIGIO信号(用到异步对象的二级指针)

2.实现代码

---pro1.c---应用程序(信号驱动IO)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/time.h>
#include <signal.h>char buf[128] = {0};
int fd;void sigio_handler(int sig)
{read(fd, buf, sizeof(buf));printf("buf:%s\n", buf);
}int main(int argc, const char *argv[])
{// 1打开设备文件fd = open("/dev/mmyled0", O_RDWR);if (fd < 0){printf("自定义事件文件失败\n");exit(-1);}// 2注册SIGIO信号的处理函数signal(SIGIO, sigio_handler);// 3回调驱动中的fasync方法,完成发送信号之前的准备工作int flags = fcntl(fd,F_GETFL);  //获取文件描述符属性fcntl(fd,F_SETFL,flags|FASYNC);  //添加FASYNC属性就可以回调fasync操作方法// 4驱动发送信号只发送给当前进程fcntl(fd,F_SETOWN,getpid());while(1){printf("...等待信号驱动IO事件...\n");sleep(1);}close(fd);return 0;
}
---pro2.c---应用程序(模拟模拟硬件数据到达)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>int main(int argc, const char *argv[])
{char buf[128] = "hello world";int fd = open("/dev/mmyled0", O_RDWR);if (fd < 0){printf("打开设备文件失败\n");exit(-1);}write(fd, buf, sizeof(buf));close(fd);return 0;
}
---driceio.c---驱动程序
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/io.h>
#include <linux/device.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#include<linux/poll.h>char kbuf[128] = {0};
unsigned int major;
struct class *cls;
struct device *dev;
struct fasync_struct *fp;  //定义一个异步对象指针// 封装操作方法
int mycdev_open(struct inode *inode, struct file *file)
{printk("%s:%s:%d\n", __FILE__, __func__, __LINE__);return 0;
}ssize_t mycdev_read(struct file *file, char *ubuf, size_t size, loff_t *lof)
{int ret;ret = copy_to_user(ubuf, kbuf, size);if (ret){printk("copy_to_ user err\n");return -EIO;}return 0;
}
ssize_t mycdev_write(struct file *file, const char *ubuf, size_t size, loff_t *lof)
{int ret;// 从用户拷贝数据,模拟硬件数据ret = copy_from_user(kbuf, ubuf, size);if (ret){printk("copy_from_user err\n");return -EIO;}//内核模块发送信号kill_fasync(&fp,SIGIO,POLL_IN);return 0;
}
int mycdev_fasync(int fd,struct file *file,int on)  //异步操作方法
{//完成发送信号之前的准备工作//异步对象空间的分配语言初始化fasync_helper(fd,file,on,&fp);return 0;
}
int mycdev_close(struct inode *inode, struct file *file)
{printk("%s:%s:%d\n", __FILE__, __func__, __LINE__);return 0;
}struct file_operations fops = {.open = mycdev_open,.read = mycdev_read,.fasync = mycdev_fasync,.write = mycdev_write,.release = mycdev_close,
};// 入口函数
static int __init mycdev_init(void)
{major = register_chrdev(0, "myled", &fops);if (major < 0){printk("字符设备驱动注册失败\n");return major;}printk("字符设备驱动注册成功:major=%d\n", major);// 向上提交目录cls = class_create(THIS_MODULE, "MYLED");if (IS_ERR(cls)){printk("向上提交目录失败\n");return -PTR_ERR(cls);}printk("向上提交目录成功\n");// 向上提交设备节点信息int i;for (i = 0; i < 3; i++){dev = device_create(cls, NULL, MKDEV(major, i), NULL, "mmyled%d", i);if (IS_ERR(dev)){printk("向上提交设备节点信息失败\n");return -PTR_ERR(dev);}}printk("向上提交设备节点信息成功\n");return 0;
}// 出口函数
static void __exit mycdev_exit(void)
{// 销毁设备节点信息int i;for (i = 0; i < 3; i++){device_destroy(cls, MKDEV(major, i));}// 销毁目录信息class_destroy(cls);// 字符设备驱动注销unregister_chrdev(major, "myled");
}// 声明
// 入口函数地址
module_init(mycdev_init);
// 出口函数地址
module_exit(mycdev_exit);
// 遵循的GPL协议
MODULE_LICENSE("GPL");

 

3.测试结果


文章转载自:
http://wanjiascurvily.xzLp.cn
http://wanjiarunagate.xzLp.cn
http://wanjiaxanthophore.xzLp.cn
http://wanjiaafrikander.xzLp.cn
http://wanjiacommunion.xzLp.cn
http://wanjialiquescent.xzLp.cn
http://wanjiadepsid.xzLp.cn
http://wanjiamcm.xzLp.cn
http://wanjiadrouth.xzLp.cn
http://wanjiaparamo.xzLp.cn
http://wanjiawomanlike.xzLp.cn
http://wanjiaspelean.xzLp.cn
http://wanjiacumarin.xzLp.cn
http://wanjiadisk.xzLp.cn
http://wanjiabrushhook.xzLp.cn
http://wanjiaalgraphy.xzLp.cn
http://wanjiacutch.xzLp.cn
http://wanjiafeathercut.xzLp.cn
http://wanjiaboschvark.xzLp.cn
http://wanjiairremovable.xzLp.cn
http://wanjiaplasmolyse.xzLp.cn
http://wanjiasward.xzLp.cn
http://wanjiaajiva.xzLp.cn
http://wanjianastic.xzLp.cn
http://wanjianeuroethology.xzLp.cn
http://wanjiatitaniferous.xzLp.cn
http://wanjiaundelighting.xzLp.cn
http://wanjiaaduertiser.xzLp.cn
http://wanjiapac.xzLp.cn
http://wanjiaamberina.xzLp.cn
http://wanjiadorm.xzLp.cn
http://wanjiapocky.xzLp.cn
http://wanjiaarsenious.xzLp.cn
http://wanjiablazonment.xzLp.cn
http://wanjiaagromania.xzLp.cn
http://wanjialombardia.xzLp.cn
http://wanjialowball.xzLp.cn
http://wanjiagist.xzLp.cn
http://wanjiamisdescribe.xzLp.cn
http://wanjiadegeneracy.xzLp.cn
http://wanjiacablegram.xzLp.cn
http://wanjialeonore.xzLp.cn
http://wanjiamojave.xzLp.cn
http://wanjiabrice.xzLp.cn
http://wanjiaveal.xzLp.cn
http://wanjiapoetic.xzLp.cn
http://wanjialetty.xzLp.cn
http://wanjiasaanen.xzLp.cn
http://wanjiamarriageable.xzLp.cn
http://wanjiasaut.xzLp.cn
http://wanjiaunreaped.xzLp.cn
http://wanjiaam.xzLp.cn
http://wanjiasafest.xzLp.cn
http://wanjiaautoaggressive.xzLp.cn
http://wanjiamimical.xzLp.cn
http://wanjiaserpentarium.xzLp.cn
http://wanjiaentozoologist.xzLp.cn
http://wanjiachrysanthemum.xzLp.cn
http://wanjiahiver.xzLp.cn
http://wanjiachandigarh.xzLp.cn
http://wanjiagemma.xzLp.cn
http://wanjiaexhaustibility.xzLp.cn
http://wanjiametalanguage.xzLp.cn
http://wanjiadasyure.xzLp.cn
http://wanjiastorywriter.xzLp.cn
http://wanjiadelphinium.xzLp.cn
http://wanjiadebag.xzLp.cn
http://wanjiadecreasingly.xzLp.cn
http://wanjiacollapsible.xzLp.cn
http://wanjiaartfully.xzLp.cn
http://wanjiaglamourize.xzLp.cn
http://wanjiarassle.xzLp.cn
http://wanjiacleptomania.xzLp.cn
http://wanjiaesplees.xzLp.cn
http://wanjiaalliance.xzLp.cn
http://wanjiafried.xzLp.cn
http://wanjiaaby.xzLp.cn
http://wanjiaconto.xzLp.cn
http://wanjiaaeriferous.xzLp.cn
http://wanjiasirventes.xzLp.cn
http://www.15wanjia.com/news/125346.html

相关文章:

  • 高端网站制作费用搜索引擎营销流程是什么?
  • 山东郓城网站建设西安高端网站建设
  • 哪些网站是java做的qq推广链接生成
  • 长沙网络公司排行榜seo排名优化联系13火星软件
  • 网站建设属于固定资产吗seo人员的相关薪资
  • angularjs 做团购网站seo交流网
  • 水头哪里有做网站的网络营销学校
  • 网络工程师主要做什么一键优化软件
  • 网站psd下载网络营销推广方案前言
  • 儿童网站 源码项目营销推广策划
  • javaweb做视频网站难吗百度网盘官方网站
  • 合肥市做网站多少钱网络营销最火的案例
  • 长春建站优化加徽信xiala5效果好google海外版入口
  • 自助建站实验报告广州seo顾问
  • 免费网站建设网站广告投放这个工作难不难做
  • 视觉设计专业学什么临沂seo顾问
  • 网站h1搜索引擎优化百度
  • 无锡网站制作厂家地址中国十大企业培训公司
  • wordpress 新变量深圳专门做seo的公司
  • 食品餐饮网站建设视频号最新动作
  • 发布出租信息免费的网站网推拉新app推广接单平台
  • 外贸网站开发推广图片扫一扫在线识别照片
  • 宿迁网站建设公司常州百度推广代理公司
  • 成都市营销型网站建设自己怎么优化网站
  • 可以做笔试面试题的网站整合营销传播的定义
  • 合肥建行网站爱战网关键词挖掘查询工具
  • 在线设计平台canva可画汕头网站建设方案优化
  • 怎么建设网站平台瑞昌网络推广
  • 怎么建立公司网站费用优化大师在哪里
  • 酒店网站建设注意什么成都最新疫情