《linux设备驱动程序》3rd 简称ldd3,在第三章高级字符设备驱动中介绍了信号量机制后,我查看了ldd3附带的源代码,对其中某些部分不理解,请教各位:
在scull.h中定义结构的,如下
/*
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 semaphore sem; /* mutual exclusion semaphore */ 这里定义的结构中包含了信号量
struct cdev cdev; /* Char device structure */
};
在main.c中定义了全局变量 struct scull_dev *scull_devices; /* allocated in scull_init_module */