Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Linux Device Driver Development Cookbook

You're reading from  Linux Device Driver Development Cookbook

Product type Book
Published in May 2019
Publisher Packt
ISBN-13 9781838558802
Pages 356 pages
Edition 1st Edition
Languages
Author (1):
Rodolfo Giometti Rodolfo Giometti
Profile icon Rodolfo Giometti

Table of Contents (14) Chapters

Preface Installing the Development System A Peek Inside the Kernel Working with Char Drivers Using the Device Tree Managing Interrupts and Concurrency Miscellaneous Kernel Internals Advanced Char Driver Operations Additional Information: Working with Char Drivers Additional Information: Using the Device Tree Additional Information: Managing Interrupts and Concurrency Additional Information: Miscellaneous Kernel Internals Additional Information: Advanced Char Driver Operations Other Books You May Enjoy

Kernel hash tables

As stated previously, for linked lists, when working with the Linux's hash table interface, we should always bear in mind that these hashing functions perform no locking, so it is possible that our device driver (or other kernel entities) could attempt to perform concurrent operations on the same hash table. This is why we must be sure to also implement a good locking scheme to protect our data against race conditions.

As with kernel lists, we can declare and then initialize a hash table with a size of power-of-2 bits, using the following code:

DECLARE_HASHTABLE(data_hash, bits)
hash_init(data_hash);
As per lists, we have the compile time counterpart macro DEFINE_HASHTABLE(), which can be used to do the same in case of a non-dynamic hash table allocation. In our example, we can use DEFINE_HASHTABLE(data_hash, bits);

This creates and initializes a table named...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}