收藏 分销(赏)

大学专业试卷linux设备驱动程序设计A.doc

上传人:二*** 文档编号:4518878 上传时间:2024-09-26 格式:DOC 页数:2 大小:62KB
下载 相关 举报
大学专业试卷linux设备驱动程序设计A.doc_第1页
第1页 / 共2页
本文档共2页,全文阅读请下载到手机保存,查看更方便
资源描述
院系:—————— 专业班级:——————— 姓名:——————— 学号:—————— 装 订 线 《linux设备驱动程序设计》课程试卷A 适用专业: 考试日期: 闭卷 所需时间:120分钟 总分:100分 一、 填空题(每空1分,共10分) 1. 驱动程序全称为______________,是一种可以使计算机和________通信的特殊程序。 2. Linux设备驱动程序可以分为__________、__________、___________三类。 3. Linux内核主要由以下五个子系统组成____________、__________ ____________、_______________、________________ 二、 问答题(每题10分,共70分) 1. 什么是设备驱动?请详细说明 (10分) 2. 无操作系统和有操作系统的设备驱动的区别在哪里?为什么要使用操作系统? (10分) 3. 驱动程序可以分为哪两类?请举例说明 (10分) 4. LINUX中引入了“模块”的概念,那么什么是“模块”?它有什么特点? (10分) 主设备号和次设备号是什么?LINUX中如何使用它们?(10分) 5. MAKEFILE的用途是什么?下面是一个简单的MAKEFILE文件,试分析其每句的功能 (10分) aaa = hello.o hello:global.o $(aaa) hello.o: global.h global.o:global.h clean: rm *.o hello 7. 常用的驱动编写相关的命令有以下几个,请分别写出它们的用途: (10分) printk Insmod Lsmod Rmmod Dmesg 三、程序阅读(共20分) 下面是一个比较完整的驱动程序例子,请阅读代码,详细写出每段的意义 (每空2分,共20分) 头文件 略 MODULE_LICENSE("GPL"); #define MAJOR_NUM 252 ① static ssize_t hello_read(struct file *, char *, size_t, loff_t * off); static ssize_t hello_write(struct file *, const char *, size_t, loff_t * off); static int hello_open(struct inode *inode,struct file *filp); static int hello_release(struct inode *inode,struct file *filp); struct file_operations hello_fops = { open: hello_open, read: hello_read, write: hello_write, release:hello_release, }; ② static int global_var = 0; static int __init hello_init(void) { int ret; ret = register_chrdev(MAJOR_NUM, "hello", &hello_fops); if (ret) { printk("hello register failure!\n"); } else { printk("hello register success!\n"); } return ret; } ③ static void __exit hello_exit(void) { int ret; ret = unregister_chrdev(MAJOR_NUM, "hello"); if (ret) { printk("hello unregister failure\n!"); } else { printk("hello unregister success!\n"); } } ④ static int hello_open(struct inode *inode,struct file *filp) { printk("this is hello_open!\n"); return 0; } ⑤ static int hello_release(struct inode *inode,struct file *filp) { printk("this is hello_release!\n"); return 0; } ⑥ static ssize_t hello_read(struct file *filp, char *buf, size_t len, loff_t *off) { printk("this is hello_read!\n"); if (copy_to_user(buf, &global_var, sizeof(int))) { return 0; } return sizeof(int); } ⑦ static ssize_t hello_write(struct file *filp, const char *buf, size_t len, loff_t *off) { printk("this is hello_write!\n"); if (copy_from_user(&global_var, buf, sizeof(int))) { return 0; } return sizeof(int); } ⑧ module_init(hello_init); ⑨ module_exit(hello_exit); ⑩
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传
相似文档                                   自信AI助手自信AI助手

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服