初学驱动之 scull 为何物?
首先看scull 设备的结构体的一个定义:
struct scull_dev {
struct scull_qset *data; /* Pointer to first quantum set. */
int quantum; /* The current quantum size. */
int qset; /* The current array size. */
unsigned long size; /* Amount of data stored here. */
unsigned int access_key; /* Used by sculluid and scullpriv. */
struct mutex mutex; /* Mutual exclusion semaphore. */
struct cdev cdev; /* Char device structure. */
};
这里面的scull是什么意思? (还是要看原文啊 不然还以为是个新的单词)
scull(simple character utility for loading localities,区域装载的简单字符工具)是一个操作内存区域的字符设备驱动程序,这片内存区域就相当于一个字符设备。
还是看图说话,比较方便
因为先是要有基本的单元,其次是用链表连接起来这些基本的单元,然后组成一个集合。
至于名字叫做量子,那就无所谓了,反正主要主要是为了方便简单的内存分配。