



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




















An introduction to the use of kernel timers and work queues
struct mystruct { char w; short x; long y; long long z; } my_instance;
You can use the ‘sizeof’ operator to find out how much memory gets allocated to any ‘struct mystruct’ object, like this: int nbytes = sizeof( my_instance );
You can use the ‘offsetof’’ operator to find out where within a given structure a particular field occurs, like this: int offset_z = offsetof( struct mystruct, z );
struct mystruct { char w; short x; long y; long long z; } my_instance = { 1, 2, 3, 4 };
If you have a pointer to one of the fields in some instance of a this kind of ‘struct’ object, then you could use the ‘container_of()’ macro to get a pointer to that ‘struct’ object itself, like this:
long *ptr = &my_instance.y; struct mystruct *p = container_of( ptr, struct mystruct, y );
This would be useful if you now wanted to access other members:
printk( “w=%d x=%d y=%d z=%d \n”, p->w, p->x, p->y, p->z );