收藏 分销(赏)

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

上传人:二*** 文档编号:4518878 上传时间:2024-09-26 格式:DOC 页数:2 大小:62KB
下载 相关 举报
大学专业试卷linux设备驱动程序设计A.doc_第1页
第1页 / 共2页
亲,该文档总共2页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

1、院系: 专业班级: 姓名: 学号: 装 订 线linux设备驱动程序设计课程试卷A适用专业: 考试日期: 闭卷所需时间:120分钟 总分:100分 一、 填空题(每空1分,共10分)1. 驱动程序全称为_,是一种可以使计算机和_通信的特殊程序。2. Linux设备驱动程序可以分为_、_、_三类。3. Linux内核主要由以下五个子系统组成_、_、_、_二、 问答题(每题10分,共70分)1 什么是设备驱动?请详细说明 (10分)2 无操作系统和有操作系统的设备驱动的区别在哪里?为什么要使用操作系统? (10分)3 驱动程序可以分为哪两类?请举例说明 (10分)4 LINUX中引入了“模块”的概

2、念,那么什么是“模块”?它有什么特点? (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分) 下面是一个比较完整的驱动程序例子,

3、请阅读代码,详细写出每段的意义 (每空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 hel

4、lo_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(h

5、ello register failure!n);elseprintk(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 failuren!);elseprintk(hello unregister success!n); static int hello_open(struct inode *inode,struct file *filp

6、)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);

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

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

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

关于我们      便捷服务       自信AI       AI导航        获赠5币

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

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

gongan.png浙公网安备33021202000488号   

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

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服