文章目錄 Creating the ImageUsing the Image quoted from http://www.omninerd.com/articles/Installing_GRUB_on_a_Hard_Disk_Image_File IntroductionGRUB is the GRand Unified Bootloader. For those unfamiliar, a bootloader is a
產生競爭的原因: 對資源的共用訪問,包括硬體資源(裝置)和軟體資源(記憶體空間) 原則: 盡量減少共用資源的使用,如全域變數等 解決的方法: 通過建立critical section是操作成為原子操作,使同一時間內,只有一個線程操作該段代碼。 kernel對不同的情況提供了不同的方法,注意的是,有的方法可以 Go to sleep的,有的不行! 有的方法會導致執行的線程go to sleep,而有的方法不會。 有的代碼是允許sleep的,那就可以使用go to
The following mechanisms are available in the kernel to defer work to a bottom half: softirqs, tasklets, and work queues. Softirqs are the basic bottom half mechanism and have strong locking requirements. They are used only by afew
Char devices are accessedthrough names in the filesystem. Those names arecalled special files or device files or simply nodes of thefilesystem tree; they are conventionally located in the/dev directory. Special filesfor char drivers are
When you are outside of process context (i.e., in interrupt context), you must observe thefollowing rules: • No access to user space is allowed. Because there is no process context, there is no path to the user space associated with any
/* * procfs3.c - create a "file" in /proc, use the file_operation way * to manage the file. */#include <linux/kernel.h> /* We're doing kernel work */#include <linux/module.h> /* Specifically, a module
GCC的組合語言用的是AT&T的文法。 源檔案:test.c#include <stdio.h>#include <fcntl.h>int swap(int *a, int *b){ int c ; c = *a; *a = *b; *b = c; return c;}int main(int argc, char *argv[]){ int a, b, c; a = 16; b = 32; c = swap(&a, &b); return 1;
Concurrency IV -- Spinlock, may be used in code that can't sleepPinciples for using spinlock1. CANNOT sleep when holding a spinlock2. disable preemption before holding a apinlock this is done by kernel, the spinlock code itself3. disable the