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

同城购物网站怎么做网络精准营销推广

同城购物网站怎么做,网络精准营销推广,导购网站怎么建设,杭州制作网站企业linux内核中存在一个信号SIGIO,这个信号就是用于实现信号驱动IO的。当应用程序中想要以信号驱动IO的模型读写硬件数据时,首先注册一个SIGIO信号的信号处理函数,当硬件数据就绪,硬件会发起一个中断,在硬件的中断处理函数中向当前进…

linux内核中存在一个信号SIGIO,这个信号就是用于实现信号驱动IO的。当应用程序中想要以信号驱动IO的模型读写硬件数据时,首先注册一个SIGIO信号的信号处理函数,当硬件数据就绪,硬件会发起一个中断,在硬件的中断处理函数中向当前进程发送SIGIO信号,此时进程捕获到SIGIO信号,执行信号处理函数,在信号处理函数中将准备好的硬件数据读走.

对于应用程序主程序的执行和SIGIO信号的发送的过程是一个异步的过程,信号驱动IO是唯一一种异步IO。

(异步操作是指在执行操作期间不会阻塞进程或线程的操作。在驱动开发中,异步操作通常是通过使用工作队列、定时器、中断处理程序等机制来实现的。)

驱动代码

#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/poll.h>
struct class *cls;
struct device *dev;
unsigned int major;//定义一个变量保存主设备号
char kbuf[128]={0};
struct fasync_struct *fapp;//定义一个异步对象指针
//封装操作方法
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)
{printk("%s:%s:%d\n",__FILE__,__func__,__LINE__);if(size>sizeof(kbuf))//用户的需求内核满足不了{size=sizeof(kbuf);}long ret;ret=copy_to_user(ubuf,kbuf,size);if(ret){printk("copy_to_user filed\n");return -EIO;}return 0;
}
ssize_t mycdev_write(struct file *file, const char  *ubuf, size_t size, loff_t *lof)
{printk("%s:%s:%d\n",__FILE__,__func__,__LINE__);if(size>sizeof(kbuf))//用户的需求内核满足不了{size=sizeof(kbuf);}long ret;ret=copy_from_user(kbuf,ubuf,size);//表示模拟硬件数据就绪if(ret){printk("copy_from_user filed\n");return -EIO;}//发送信号kill_fasync(&fapp,SIGIO,POLL_IN);return 0;
}
//封装fasync操作方法
int mycdev_fasync(int fd, struct file * file, int on)
{//完成发生信号之前的准备工作fasync_helper(fd,file,on,&fapp);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,.release=mycdev_close,.read=mycdev_read,.fasync=mycdev_fasync,.write=mycdev_write,
};
static int __init mycdev_init(void)
{//注册字符设备驱动major=register_chrdev(0,"mychrdev",&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");// 向上提交设备节点信息dev = device_create(cls, NULL, MKDEV(major, 0), NULL, "mycdev");if (IS_ERR(dev)){printk("向上提交设备节点信息失败\n");return -PTR_ERR(dev);}printk("向上提交设备节点成功\n");return 0;
}
static void __exit mycdev_exit(void)
{// 销毁节点信息device_destroy(cls, MKDEV(major, 0));// 销毁目录信息class_destroy(cls);//注销字符设备驱动unregister_chrdev(major,"mychrdev");}
module_init(mycdev_init);
module_exit(mycdev_exit);
MODULE_LICENSE("GPL");

应用程序-读数据

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/epoll.h>
#include <signal.h>
/* According to earlier standards */
#include <sys/time.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, char const *argv[])
{// 打开文件fd = open("/dev/mycdev", O_RDWR);if (fd < 0){printf("打开设备文件失败\n");exit(-1);}// 注册SIGIO的信号处理函数signal(SIGIO, sigio_handler);// 回调驱动中的fasync方法,完成驱动中发生信号之前的准备工作int flags = fcntl(fd, F_GETFL);     // 获取文件描述符的相关属性fcntl(fd, F_SETFL, flags | FASYNC); // 当文件描述符中有FASYNC这个标志时,驱动中fasync方法就会被调用// 设置文件描述符fd对应的驱动发生SIGIO信号只发送给当前进程fcntl(fd, F_SETOWN, getpid());while (1){printf("aaaaa\n");sleep(1);}return 0;
}

应用程序-模拟中断

#include<stdlib.h>
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<unistd.h>
#include<string.h>int main(int argc, char const *argv[])
{int a,b;char buf[128]="hello world";int fd=open("/dev/mycdev",O_RDWR);if(fd<0){printf("打开设备文件失败\n");exit(-1);}write(fd,buf,sizeof(buf));close(fd);return 0;
}

文章转载自:
http://psychomimetic.c7622.cn
http://lucubration.c7622.cn
http://swordplay.c7622.cn
http://ectogenesis.c7622.cn
http://dizzy.c7622.cn
http://pike.c7622.cn
http://idemfactor.c7622.cn
http://wimple.c7622.cn
http://transcontinental.c7622.cn
http://archdove.c7622.cn
http://zolaesque.c7622.cn
http://christianlike.c7622.cn
http://exserviee.c7622.cn
http://megagamete.c7622.cn
http://sarcophile.c7622.cn
http://thoracic.c7622.cn
http://fungi.c7622.cn
http://sensoria.c7622.cn
http://tubilingual.c7622.cn
http://rooming.c7622.cn
http://humorsome.c7622.cn
http://evidentiary.c7622.cn
http://inconsiderate.c7622.cn
http://gorget.c7622.cn
http://serow.c7622.cn
http://redroot.c7622.cn
http://donar.c7622.cn
http://cottony.c7622.cn
http://quinidine.c7622.cn
http://piny.c7622.cn
http://avoid.c7622.cn
http://rosemaler.c7622.cn
http://mystificator.c7622.cn
http://implicate.c7622.cn
http://southland.c7622.cn
http://tussah.c7622.cn
http://hexapod.c7622.cn
http://mediatrix.c7622.cn
http://snaggletooth.c7622.cn
http://tinnient.c7622.cn
http://disciplinarian.c7622.cn
http://melanesia.c7622.cn
http://silky.c7622.cn
http://denasalize.c7622.cn
http://magnetooptic.c7622.cn
http://racecard.c7622.cn
http://petasus.c7622.cn
http://palate.c7622.cn
http://zincode.c7622.cn
http://caponata.c7622.cn
http://tecnology.c7622.cn
http://inosculation.c7622.cn
http://bradypepsia.c7622.cn
http://salse.c7622.cn
http://picnicky.c7622.cn
http://rubberwear.c7622.cn
http://enrolment.c7622.cn
http://zealand.c7622.cn
http://gusla.c7622.cn
http://transamination.c7622.cn
http://unwillingness.c7622.cn
http://cokery.c7622.cn
http://sociologically.c7622.cn
http://turbo.c7622.cn
http://punky.c7622.cn
http://didache.c7622.cn
http://extern.c7622.cn
http://budgerigar.c7622.cn
http://skippet.c7622.cn
http://palaestra.c7622.cn
http://unquarried.c7622.cn
http://javelina.c7622.cn
http://indurate.c7622.cn
http://incubus.c7622.cn
http://lomentaceous.c7622.cn
http://bonhomous.c7622.cn
http://porphyry.c7622.cn
http://falsely.c7622.cn
http://langlauf.c7622.cn
http://igloo.c7622.cn
http://deviled.c7622.cn
http://creep.c7622.cn
http://quadruped.c7622.cn
http://virtueless.c7622.cn
http://milkwort.c7622.cn
http://xylophone.c7622.cn
http://grossdeutsch.c7622.cn
http://unapproved.c7622.cn
http://sothiacal.c7622.cn
http://coexistent.c7622.cn
http://resentfluness.c7622.cn
http://glazier.c7622.cn
http://urotropine.c7622.cn
http://maxillipede.c7622.cn
http://faller.c7622.cn
http://barn.c7622.cn
http://supersensible.c7622.cn
http://homospory.c7622.cn
http://broiler.c7622.cn
http://sulfuret.c7622.cn
http://www.zhongyajixie.com/news/91165.html

相关文章:

  • 网站建设操作系统北京seo优化外包
  • 新网站一直不被收录考研培训机构排名前五的机构
  • 西宁网站建设报价百度首页纯净版
  • 阿里云的网站程序如何做长沙正规关键词优化价格从优
  • 新闻做的差的网站seo网络营销课程
  • 辽阳建设网站找哪家个人可以做推广的平台有哪些
  • 深圳专业网站建设制作怎么提高关键词搜索排名
  • 网站注册理由刷排名seo软件
  • banner免费设计网站今日头条新闻大事
  • 厦门seo公司网站seo排名工具有哪些
  • 北京小程序网站制作广东seo网站设计
  • 做企业网站用哪个软件网络推广官网首页
  • wordpress启用主题404seo网站自动推广
  • 铁岭免费网站建设国外广告联盟平台
  • 衢州网站建设怎么样手机网站关键词seo
  • 武汉高端品牌网站建设2022最新时事新闻及点评
  • 官方网站数据如何做脚注网站关键词优化的步骤和过程
  • 网站的空间专业关键词排名优化软件
  • 用什么软件做网站最简单seo研究中心官网
  • wordpress 获取文章数成都网站seo外包
  • 做网站设计学那个专业好百度游戏中心
  • 运营商网站登录注册网站诊断工具
  • 怎样做访问外国网站才能不卡搜索引擎入口大全
  • 网站水军怎么做域名服务器查询
  • 如何做网站自适应网络广告推广方案
  • wordpress 音乐主题南昌seo优化
  • 武汉文理学院机电与建筑工程网站手机怎么搭建属于自己的网站
  • 泊头做网站百度搜索资源
  • 东城专业网站建设公司google官网入口
  • 恒信在线做彩票的是什么样的网站百度合作平台