Synchronization in Linux Kernel Programming
What you'll learn
- Synchronization concepts in Linux Kernel
Requirements
- Should be able to write/understand Hello World Linux Kernel Module
- Should be able to write/understand Linux Kernel Modules for /proc filesystem
Description
Update: Sep 15: Added RCU Section
What you will learn in this course
Various concepts related to concurrency like: preemption, context switch, reentrancy, critical section, race condition
Various Synchronization techniques
Per CPU Variables
Atomic Variables
Spinlocks
Semaphores
Mutexes
Read Write Locks
Sequence Locks
Read Copy Update(RCU)
API's/Macros/Structures:
spinlock_t, DEFINE_SPINLOCK, spin_lock, spin_unlock, spin_trylock, spin_lock_irqsave, spin_unlock_irqrestore,spin_lock_irq, spin_unlock_irq
atomic_t, atomic64_t, ATOMIC_INIT, atomic_inc, atomic_dec, atomic_set, atomic_read, atomic_add, atomic_sub,
atomic_dec_and_test, atomic_inc_and_test, atomic_sub_and_test, atomic_add_negative,atomic_add_return, atomic_sub_return, atomic_inc_return, atomic_dec_return,atomic_fetch_add, atomic_fetch_sub, atomic_cmpxchg, atomic_xchg,set_bit, clear_bit, change_bit, test_and_set_bit, test_and_clear_bit, test_and_change_bit,
NR_CPUS,num_online_cpus,smp_processor_id,get_cpu,put_cpu,DEFINE_PER_CPU,get_cpu_var, put_cpu_var, per_cpu, for_each_online_cpu, alloc_percpu, free_percpu, per_cpu_ptr
rcu_read_lock, rcu_read_unlock, synchronize_rcu, call_rcu, rcu_assign_pointer, rcu_dereference
seqlock_t, seqcount_t, DEFINE_SEQLOCK, seqlock_init, write_seqlock, write_sequnlock
struct rw_semaphore, DECLARE_RWSEM, init_rwsem, down_read, up_read, down_write, up_write, down_read_trylock, down_write_trylock, downgrade_write
struct rwlock_t, DEFINE_RWLOCK, rwlock_init, read_lock, read_unlock, write_lock, write_unlock
struct mutex, DEFINE_MUTEX, mutex_init, mutex_lock, mutex_unlock, mutex_trylock, mutex_lock_interruptible, mutex_unlock_interruptible, mutex_is_locked
struct semaphore, sema_init, DEFINE_SEMAPHORE, down, up, down_interruptible, down_trylock, down_timeout, down_killable
Commands used in the course
nproc
ps -eaF
ps aux
Who this course is for:
- Linux Kernel Developers interested in learning various synchronization techniques
Course content
- Preview01:01
- Preview03:01
- Preview07:53
- Preview03:43
- Preview02:47
- 00:46When can kernel preemption happen
- 02:12Example of kernel preemption
- 03:12Reentrancy
- 02:10Synchronization Race Condition and critical regions
- 01:02Causes of concurrency
- 02:11Solution for concurrency
- 02:23Find out maximum number of processors in Kernel
- 01:37Find out which processor is running kernel control path
- 01:39Linux Kernel Module Example of processor id of Kernel Thread
- 02:54Linux Kernel Module Example of processor id on uniprocessor system
Instructor
I have been working on Linux for more than 7 years. I have seen many people still lack their skills on Linux. So, i am working on courses for Linux which will make them Learn Linux in an easy way. The agenda of my courses will be more practical and less theoretical. Show more examples and you will easily grab the concepts.