Ưu đãi trong tuần: Nhập mã UD50 giảm 50k cho đơn từ 300k!
Trang chủ
Menu

Synchronization in Linux Kernel Programming

Đồng bộ hóa trong Lập trình Linux Kernel

Đồng bộ hóa trong Lập trình Linux Kernel

Lập trình Linux Kernel - Đồng bộ hóa và Xử lý đồng thời

4.4
(200 đánh giá)
2,431 học viên
Giảng viên
Linux Trainer
Phụ đề Việt chất lượng cao Phụ đề tiếng Anh Bán chạy Đánh giá cao
50.000đ 349.000đ -86%
✓ Xem giỏ hàng và thanh toán
Bao gồm phụ đề tiếng Việt, tiếng Anh
4.5 giờ video
120 bài giảng
Truy cập vĩnh viễn
Học trên mọi thiết bị
Cập nhật: 30/05/2026

Bạn sẽ học được gì

Các khái niệm đồng bộ hóa trong Linux Kernel

Yêu cầu

Có thể viết/hiểu được Kernel Module Hello World
Có thể viết/hiểu được Kernel Module cho hệ thống tệp /proc

Đối tượng phù hợp

Dành cho nhà phát triển Linux Kernel muốn học các kỹ thuật đồng bộ hóa

Nội dung khóa học

11 phần • 120 bài giảng
1 Vấn đề
2 Giới thiệu về xử lý đồng thời
3 Bối cảnh của Hệ thống đa xử lý
4 Preemption và chuyển đổi ngữ cảnh trong Linux Kernel
5 Preemption trong không gian người dùng và kernel
6 Khi nào kernel có thể preempt
7 Ví dụ về kernel preemption
8 Khả năng tái nhập
9 Điều kiện tranh chấp đồng bộ hóa và vùng tới hạn
10 Nguyên nhân gây ra xử lý đồng thời
11 Giải pháp cho xử lý đồng thời
12 Tìm số lượng bộ xử lý tối đa trong Kernel
13 Tìm bộ xử lý nào đang chạy kernel control path
14 Ví dụ Kernel Module: ID bộ xử lý của Kernel Thread
15 Ví dụ Kernel Module: ID bộ xử lý trên hệ thống đơn xử lý
1 Giới thiệu
2 Ví dụ về biến Per CPU
3 Giao diện mới cho biến Per CPU
4 Ví dụ về giao diện mới của biến Per CPU
5 Ví dụ về per cpu
6 Ví dụ về for_each_online_cpu
7 Cấp phát dữ liệu per cpu tại thời gian chạy
8 Vấn đề với biến Per CPU
1 Vấn đề Đọc - Sửa đổi - Ghi
2 Giới thiệu về toán tử Atomic
3 Ví dụ về toán tử Atomic
4 Các ứng dụng phổ biến của thao tác Atomic
5 Thao tác Atomic và kiểm tra
6 Atomic cộng/trừ và trả về giá trị
7 Các thao tác Atomic khác
8 Thao tác Atomic 64-bit
9 Thao tác bitwise Atomic
10 Thao tác bitwise Atomic có giá trị trả về
11 Thao tác bitwise không Atomic
1 Giới thiệu
2 API của spinlock
3 Khởi tạo spinlock
4 Ví dụ spinlock với hai kernel thread
5 Điều gì xảy ra nếu tôi acquire một lock đã được CPU khác giữ
6 Triển khai busyloop bằng spinlock trong char drivers
7 spin_trylock
8 Có thể dùng spinlock nếu tài nguyên được chia sẻ giữa process và interrupt context không
9 Kernel preemption có bị vô hiệu hóa khi spinlock được acquire không
10 Các điểm quan trọng cần lưu ý khi sử dụng spinlock
11 Ví dụ gọi msleep trong critical section
12 Spinlock có tồn tại trên hệ thống đơn xử lý không
13 Cách triển khai spinlock
1 Giới thiệu
2 Cách triển khai semaphore
3 Các loại semaphore
4 Có thể dùng counting semaphore trong critical section không
5 API của semaphore
6 Ví dụ Kernel Module sử dụng API semaphore
7 Ví dụ Kernel Module sử dụng down và up
8 Ví dụ Kernel Module gọi down hai lần
9 Ví dụ Kernel Module về producer consumer
10 down_interruptible
11 down_trylock
12 down_timeout
13 down_killable
14 Các điểm quan trọng khi sử dụng semaphore
15 So sánh spinlock và semaphore
1 Giới thiệu
2 So sánh mutex và semaphore
3 Cách triển khai mutex trong Linux Kernel
4 API của mutex
5 Ví dụ Kernel Module sử dụng API mutex khởi tạo động
6 Ví dụ Kernel Module sử dụng API mutex khởi tạo tĩnh
7 Ví dụ Kernel Module minh họa gọi sleep trong critical section
8 mutex_trylock
9 Điều gì xảy ra khi thread khác gọi unlock mutex
10 Thử khóa mutex đệ quy
11 mutex_is_locked
12 Nên chọn semaphore hay mutex
13 Nên chọn spinlock hay mutex
1 Bài toán
2 Giải pháp
3 Giới thiệu về ReadWrite Spinlock
4 Ví dụ Kernel Module sử dụng API RW Spinlock
5 Điều gì xảy ra khi gọi read lock và write lock liên tiếp
6 Khóa read đệ quy
7 Điều gì xảy ra khi writer đang chờ và reader xuất hiện
8 Ví dụ Kernel Module sử dụng RWLOCKS với 3 kernel thread
9 Ví dụ Kernel Module sử dụng RWLOCKS với 4 kernel thread
1 Giới thiệu về ReadWrite Semaphore
2 API của ReadWrite Semaphore
3 down_read_trylock và down_write_trylock
4 downgrade_write
5 Khóa write đệ quy
6 Ví dụ Kernel Module sử dụng nhiều thread
1 Vấn đề
2 Giải pháp
3 Sequence Locks
4 Cách hoạt động của Sequence Locks
5 Thao tác ghi trong sequence lock
6 Thao tác đọc trong sequence lock
7 Ví dụ Kernel Module sử dụng sequence lock
8 Kernel Preemption có bị vô hiệu hóa khi dùng sequence lock không
9 Hạn chế của sequence locks
10 Sequence Locks trong Linux kernel
11 Sequence locks trong interrupts
1 Giới thiệu
2 Ví dụ Linkedlist: cách xóa node không cần lock
3 Thiết kế RCU
4 Tại sao nên dùng rcu_assign_pointer
5 Thao tác đọc trong RCU
6 Tại sao nên dùng rcu_dereference
7 Ví dụ Kernel Module 1 với read và write thread
8 Ví dụ Kernel Module 2 với read và write thread
9 Khi nào nên giải phóng bộ nhớ
10 synchronize_rcu
11 call_rcu
12 RCU read side critical sections có thể lồng nhau không
13 Cách hoạt động nội bộ của synchronize_rcu
14 Thuật ngữ RCU
15 Các biến thể RCU cho Linked Lists
16 Ví dụ Kernel Module về rcu linked lists
17 Ưu điểm của RCU
18 Hỏi đáp
1 Ghi chú

Giới thiệu khóa học

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

Khóa học liên quan

Khám phá thêm các khoá học cùng chủ đề

Hiển thị tất cả khoá học C Programming
Hiển thị tất cả khoá học Linux Kernel
Hiển thị tất cả khoá học Operating Systems
Hiển thị tất cả khoá học System Programming
Zalo
Tôi có thể tư vấn khoá học cho bạn 😊