performance, stability, capability, security and protection, portability, extensibility
#ifdef__KERNEL__
/* kernel stuff */
#endif
scripts for:
sudo dd if=/dev/sda of=mbr.bin bs=512 count=1
od -xa mbr.bin
cd /etc/rc.d/init.d/
httpd stop
mics.c 中的 decompress_kernelstart_kernel开始执行,start_kernel函数变成0号进程,不再返回Start_kernel显示版本信息,调用setup_arch()初始化核心的数据结构kernel_thread()创建1号进程init进程init子进程之后,返回执行cpu_idlecd /lib/modules/2.6.32-22-generic/
find . -name "*.ko"
lsmod or cat /proc/modules
cat. This can be changed in real time by echo 1 > /proc/sys/net/ipv4/ip_forward, thus allowing IP forwarding.klogdecho commandcdrom/info: many important CD-ROM parameters#include <linux/proc_fs.h>struct proc_dir_entry* create_proc_entry(const char* name, mode_t mode, struct proc_dir_entry* parent);name, the mode mode in the directory parentNULL as parent parameterstruct proc_dir_entryfoo_file = create_proc_entry("foo", 0644, example_dir);struct proc_dir_entry* proc_mkdir(const char* name, struct proc_dir_entry* parent);name in the procfs directory parentstruct proc_dir_entry* proc_symlink(const char* name, struct proc_dir_entry* parent, const char* dest);parent that points from name to dest. this translates in userland to ln -s dest namevoid remove_proc_entry(const char* name, struct proc_dir_entry* parent);name in the directory parent from the procfs.proc_dir_entry before the function is calledtask_struct data structure:
state: process statethread_info: low-level information for the processmm: pointers to memory area descriptorstty: tty associated with the processfs: current directoryfiles: pointers to file descriptorssignal: signals receivedtgid field in process descriptor: using getpid() system calltasks field in task_struct structurelist_headprev, next fields point to the previous and the next task_structinit_taskinit: the ancestor of all processespid_hash array contains four hash tables and correspnding field in the process descriptorpid: PIDTYPE_PIDtgid: PIDTYPE_TGID (thread group leader)pgrp: PIDTYPE_PGID (group leader)session: PIDTYPE_SID (session leader)pids field of the process descriptor: the pid data structure
nr: PID numberpid_chain: links to the previous and the next elements in the hash chain listpid_list: head of the per-PID list (in thread group)TSS: a specific segment type in x86 architecture to store hardware contexts
vfork() system call: parent and child share the memory address spaceclone(), fork() and vfork() system callsclone(fn, arg, flags, child_stack, tls, ptid, ctid): creating lightweight processclone() system callfork() and vfork() system calls: implemented by clone with different parametersdo_fork() functionkernel_thread(): to create a kernel threadexit() library function_exit() system call: handled by do_exit() functionexit_group() system call: handled by do_group_exit() functionrelease_task()TIF_NEED_RESCHED in thread_info will be setnice(), setpriority() system calls
dynamic priority = max(100, min(static_priority - bonus + 5, 139))To determine whether a process is considered to be interactive or batch
bonux - 5 >= static_priority / 4 - 28sched_setparam() and sched_setscheduler() system callssched_yield() system callrunqueue data structure for each CPUrunqueue structureprio_array_t data structurescheduler_tick(): keep the time_slice counter up-to-datetry_to_wake_up() awaken a sleeping processrecalc_task_prio(): updates the dynamic priorityload_balance(): keep the runqueue of multiprocess system balancedschedule(): select a new process to runscheduler_tick()try_to_wake_up()sched_setscheduler() system call is issuedA set of CPUs whose workloads are kept balanced by the kernel
nice(): for backward compatability onlysetpriority()getpriority() and setpriority():sched_getscheduler(), sched_setscheduler(): queries/sets the scheduling policysched_getparam(), sched_setparam(): queries/sets the scheduling parameterssched_yield(): to relinquish the CPU voluntarily without being suspendedsched_get_priority_min(), sched_get_priority_max(): to return the minimum/maximum real-time static prioritysched_rr_get_interval(): to write into user space the round-robin time quantum for real-time processup(): to release a kernel semaphore (similar to signal)down(): to acquire kernel semaphore (similar to wait)init_rwsem()down_read(), down_write: acquire a read/write semaphoreup_read(),up_write(): release a read/write semaphorecomplete(): corresponding to up()wait_for_completion(): corresponding to down()cli instructionslocal_irq_disable() macrosti instructionslocal_irq_enable() macrosoftirqlocal_bh_disable() macrolocal_bh_enable() macroatomic_t type and by using atomic operationsrmdir() and rename() system calls, two semaphores requestshead.S中的 startup_32函数,最后调用 start_kernelstart_kernel,这个函数相当于应用程序里面的 main 函数start_kernel 进行一系列的初始化工作,最后将执行:smp_init:关键的一步,启动各APrest_init,调用 init 创建1号 init 进程,自身调用 cpu_idle成为0号进程init 完成剩下的工作reschedule_idle 工作过程open(), read() and write() to work regardless of file system or storage mediawrite()) => VFS (sys_write()) => file system (file system write methods) => physical medialinux/fs.hPowerManager class) and native Linux libraries in order to keep power on, otherwise Android will shut down the CPU

