I have done register, unregister the character driver successfully and also open & release the character driver successfully. In this i am facing the problem regarding to container_of().
I have done register, unregister the character driver successfully and also open & release the character driver successfully. In this i am facing the problem regarding to container_of().
local_scull_dev_ptr=container_of(pointer,container type,cdev);
anyone plz tell me the internal functioning of the this macro…
1.what i mean to say is- how the control moves…
2.we directly take the third argument as ‘cdev’…
but we know cdev resides in struct scull_dev
so we should take ‘local_scull_dev_ptr->cdev’ as a third argument…
local_dev=container_of(inode->i_cdev, struct scull_dev,cdev1);
in above function, i don’t know how container_of() give the minor number and also how assign global device to local device.
All of you are requested to “add category” to your posts. Thank You
difference b/w structure and union.
Structure:
1. It allocates memory equal to sum of memory allocated to its each individual member.
2.each member have their own memory space.
3. structure can not be implemented in shred memory.
4. it has less Ambiguity.
5. Self referential structure can be implemented in data structure.
6. All members if structure can be accessed at a time.
Union:
1.It allocates piece of memory that is Large enough to hold the Largest variable of type in union.
2. one block is used by all the members of union.
3. Union is the Best environment where memory is shared.
4. as memory is shared, Ambiguity is more in union.
5. self ref. union can not be implemented.
6. only one member is accessed at a time.
basic meaning of static variable,global variable,local variable.difference also
why char pointer take four bytes.while char take only one byte
Pgm to find the no of occurance of a word in a sentence.
int main()
{
char str1[80],str2[20],str3[20];
int i=0,j,count=0;
printf(“Enter the sentence:\n”);gets(str1);
printf(“Enter the word for which no of occurance needs to be checked:\n”);gets(str2);
while(str1[i]!=”)
{
for(j=0;str1[i]!=’ ‘;j++,i++)
str3[j]=str1[i]; //Each word of the sentence is copied to str3 & compared with str2
str3[j]=”;
if(strcmp(str3,str2)==0)
count++;
}
printf(“%s word occured %d times”,str2,count);
}
I am so surprised to see that str2 value has some garbage values aftr execution.
Though count value is incremented properly but still for some particular sentences it shows “count-1″ value.Plz help me to understand where i went wrong.
Thanks
Pushpa
how can i free memory after reading data for item, by free system call or delete the linking between qsets.
i use free system call it give me segmentation fault error
i have successfully registered the multipal devices with a driver .if anybody want to take help for it by using for loop or by call a function …..most welcome.
i have completed my registration &unregistration of multiple devices with the use of a fun scull_setup_cdev…….
I just finished with Structures and Linked Lists tonight. I have to implement Linked Lists, Queues and SCULL and I’ll do it in this week.
Char Driver : Still working on Registration and Initialization. I have to cover up a lot :/ !! Anyways, I’ll do it.
. .