Skip to Content
FreeBSD Device Drivers
book

FreeBSD Device Drivers

by Joseph Kong
April 2012
Intermediate to advanced
352 pages
8h
English
No Starch Press
Content preview from FreeBSD Device Drivers

Preventing Race Conditions

Race conditions are prevented using locks. Locks, also known as synchronization primitives, are used to serialize the execution of two or more threads. For example, the race conditions in Example 4-1, which are caused by concurrent access to race_list, can be prevented by using a lock to serialize access to race_list. Before a thread can access race_list, it must first a cquire the foo lock. Only one thread can hold foo at a time. If a thread cannot acquire foo, it cannot access race_list and must wait for the current owner to relinquish foo. This protocol guarantees that at any moment in time only one thread can access race_list, which eliminates Example 4-1’s race conditions.

There are several different types of locks ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Embedded Linux

Embedded Linux

John Lombardo
Essential Linux Device Drivers

Essential Linux Device Drivers

Sreekrishnan Venkateswaran

Publisher Resources

ISBN: 9781457166716Errata