Writing Device Drivers

Kernel Statistics

These interfaces enable device drivers to store statistics about the device in the kernel for later retrieval by applications.

kstat_t *kstat_create(char *module, int instance,  	
			char *name, char *class, uchar_t type,  	
			ulong_t ndata, uchar_t ks_flag);

kstat_create(9F) allocates and performs necessary system initialization of a kstat(9S) structure. After a successful call to kstat_create(9F), the driver must perform any necessary initialization of the data structure and then use kstat_install(9F) to make the kstat(9S) structure accessible to user applications.

void kstat_delete(kstat_t *ksp);

kstat_delete(9F) removes the kstat(9S) structure pointed to by ksp from the kernel statistics data and frees associated system resources.

void kstat_install(kstat_t *ksp);

kstat_install(9F) enables the kstat(9S) structure pointed to by ksp to be accessible by the user land applications.

void kstat_named_init(kstat_named_t *knp, char *name,  	
			uchar_t data_type);

kstat_named_init(9F) associates the name pointed to by name and the type specified in data_type with the kstat_named(9S) structure pointed to by knp.

void kstat_waitq_enter(kstat_io_t *kiop);

kstat_waitq_enter(9F) is used to update the kstat_io(9S) structure pointed to by kiop, indicating that a request has arrived but has not yet been processed.

void kstat_waitq_exit(kstat_io_t *kiop);

kstat_waitq_exit(9F) is used to update the kstat_io(9S) structure pointed to by kiop, indicating that the request is about to be serviced.

void kstat_runq_enter(kstat_io_t *kiop);

kstat_runq_enter(9F) is used to update the kstat_io(9S) structure pointed to by kiop, indicating that the request is in the process of being serviced. kstat_runq_enter(9F) is generally invoked after a call to kstat_waitq_exit(9F).

void kstat_runq_exit(kstat_io_t *kiop);

kstat_runq_exit(9F) is used to update the kstat_io(9S) structure pointed to by kiop, indicating that the request is serviced.

void kstat_waitq_to_runq(kstat_io_t *kiop);

kstat_waitq_to_runq(9F) is used to update the kstat_io(9S) structure pointed to by kiop, indicating that the request is transitioning from one state to the next. kstat_waitq_to_runq(9F) is used when a driver would normally call kstat_waitq_exit(9F) followed immediately by kstat_runq_enter(9F).

void kstat_runq_back_to_waitq(kstat_io_t *kiop);

kstat_runq_back_to_waitq(9F) is used to update the kstat_io(9S) structure pointed to by kiop indicating that the request is transitioning from one state to the next. kstat_runq_back_to_waitq(9F) is used when a driver would normally call kstat_runq_exit(9F) followed immediately by a call to kstat_waitq_enter(9F).