Professional Documents
Culture Documents
3.scull Memory
3.scull Memory
SMP
The region of memory used by scull, also called a device here, is variable in length. The more you write, the more it grows; trimming is performed by overwriting the device with a shorter file. In scull, each device is a linked list of pointers, each of which points to a Scull_Dev structure. Each such structure can refer, by default, to at most four million bytes, through an array of intermediate pointers. The released source uses an array of 1000 pointers to areas of 4000 bytes
SMP
We call each memory area a quantum and the array (or its length) a quantum set. A scull device and its memory areas are shown
Scull_Dev
Scull_Dev
SMP
Choosing the appropriate values for the quantum and the quantum set is a question of policy, rather than mechanism, and the optimal sizes depend on how the device is used. Thus, the scull driver should not force the use of any particular values for the quantum and quantum set sizes.
SMP
By setting the integer values scull_quantum and scull_qset at module load time, or
By changing both the current and default values using ioctl at runtime.
SMP
struct scull_dev {
SMP
The function scull_trim is in charge of freeing the whole data area and is invoked by scull_open when the file is opened for writing. It simply walks through the list and frees any quantum and quantum set it finds.
SMP
SMP
SMP