Linux driver example for Per CPU Variable
Per CPU Variables is an interesting feature available from Linux Kernel Version 2.6
When you define a Per CPU Variable, each processor in the system will have its own copy of the variable, hence no locking is required and better performance is achieved.
Header File: <linux/percpu.h>
To create a Per CPU Variable at compile time, use the macro:
DEFINE_PER_CPU(type, name);
E.g. DEFINE_PER_CPU(int, counter);
As linux kernel is preemptible, you must use
get_cpu_var macro to access the current processor's copy of a given variable
And finally call put_cpu_var macro after you have completed using it.
You can access another processor's copy of the variable with:
per_cpu(variable, int cpu_id);
When you define a Per CPU Variable, each processor in the system will have its own copy of the variable, hence no locking is required and better performance is achieved.
Header File: <linux/percpu.h>
To create a Per CPU Variable at compile time, use the macro:
DEFINE_PER_CPU(type, name);
E.g. DEFINE_PER_CPU(int, counter);
As linux kernel is preemptible, you must use
get_cpu_var macro to access the current processor's copy of a given variable
And finally call put_cpu_var macro after you have completed using it.
You can access another processor's copy of the variable with:
per_cpu(variable, int cpu_id);
Example:
Output:
Thanks For Sharing this Interesting Blog. it is really helpful blog. carry on. keep blogging. otherwise anyone wants to learn CREO training Course so, Contact here- +91-9311002620 or visit website- https://www.htsindia.com/Courses/cad-cam-cae/creo-for-industrial-designers-training-course
ReplyDeleteThanks for sharing this wonderful information. I too learn something new from your post..
ReplyDeletePrimavera Training in Chennai
Such a great blog.Thanks for sharing.........
ReplyDeleteGraphic Design Courses in Bangalore
Graphic Design Courses in Pune
Graphic Design Courses in Hyderabad
Graphic Design courses in Kolkata
Graphic Designing in Ahmedabad
Graphic Design courses in Kochi
Graphic Design courses in Trivandrum
Graphic Design courses in Delhi
Graphic Design courses in Gurgaon
Thank you for sharing this important conversation with the local and international community, The Electronic Repair Center can use workshop management software free trial to manage its day-to-day transactions and customer management.
ReplyDeleteVery informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. 加拿大簽證申請
ReplyDeleteGreat post. Thanks for sharing such a useful blog.
ReplyDeleteSoftware testing Training in Velachery
Software testing training in chennai
This post is so interactive and informative.keep update more information...
ReplyDeleteTally Course in Tambaram
Tally course in Chennai
Nice and informative blog! This type of information is a complete business accounting software that can be managed well whether one holds small or medium-sized businesses.
ReplyDeleteIf you want to know about Tally certification courses in Cochin then you can click here.
Thanks for sharing.