The Linux Kernel/Processing
Processing: from process to CPU
Processes and Tasks
Process is a running user space program. Kernel can start a process with function do_execve. Processes occupy system resources, like memory, CPU time. System calls sys_fork and sys_execve are used to create new processes from user space. The process exit with an sys_exit system call.
How are the process handled within the kernel?
- TODO
What are kernel threads?
- TODO
How are kernel threads handled ?
- TODO
- API: kthread_run,do_fork,do_execve,
- Implementation: current, task_struct
Synchronization
- completion - use completion for synchronization task with ISR and task or two tasks.
- #include <linux/completion.h>
- LKD2: Completion Variables
- mutex
- has owner and usage constrains
- more easy to debug then semaphore
- #include <linux/mutex.h>
- spinlock_t, timer_list, wait_queue_head_t
- semaphore - use mutex instead semaphore if possible
- #include <include/linux/semaphore.h>
- atomic operations
Bottom Halves
- tasklet is a softirq, runs in interrupt context, for time critical operations
- API: DECLARE_TASKLET, tasklet_schedule
- implemented with tasklet_struct, HI_SOFTIRQ, TASKLET_SOFTIRQ
- workqueue - works in scheduler context, for delayed operation
- API: DECLARE_WORK, schedule_work
- softirq is internal system facility and should not be used directly. Use tasklet.
- http://www.makelinux.net/books/lkd2/ch07lev1sec1
- http://www.makelinux.net/books/lkd2/ch07lev1sec2
- http://www.makelinux.net/ldd3/chp-10-sect-4
- http://www.makelinux.net/books/ulk3/understandlk-CHP-4-SECT-7
- http://www.makelinux.net/books/ulk3/understandlk-CHP-4-SECT-8
- http://www.makelinux.net/books/lkd2/ch07lev1sec1
Historical
- BH - Removed in 2.5
- Task queues - Removed in 2.5
- http://people.netfilter.org/rusty/unreliable-guides/kernel-hacking/basics-softirqs.html
- http://www.tldp.org/LDP/tlk/kernel/kernel.html