未整理の罠

prism2_csをコンパイルするときの罠

ソースのダウンロード

コンパイル

make config
make
make install

HZを変更するときの罠

HZは変更できない。 HZ=250などとしても

Kernel panic: Attempted to kill the idle task!

で止まる

ドライバをコンパイルするときの罠

supercat:/mnt/ledtest# insmod led.o
led.o: kernel-module version mismatch
        led.o was compiled for kernel version 2.5.0
        while this kernel is version 2.4.24-sh.

コンパイル時に、カーネルを一度もコンパイルしていないディレクトリをインクルードパスに指定したときに発生する
make menuconfig等 を一度でも実行し version.h を生成しないといけない。

スピンロックの罠

cat linux-2.4.24-cat709-2004-02-15b/include/asm/spinlock.h

#ifndef __ASM_SH_SPINLOCK_H
#define __ASM_SH_SPINLOCK_H

#error "No SMP on SH"

#endif /* __ASM_SH_SPINLOCK_H */

スピンロックは使えません

追記・そりゃそうだ。spinlockはsmpでのcpu同士の排他だから。プロセス同士の排他には使えません。i386でもuni-processerなら同じです。

#include <linux/sched.h>
struct semaphore mutex;

init_module(){ 
 init_MUTEX (&mutex);
}

some_function(){  
 if (down_interruptible (&mutex)){
         return -EINTR;
 }
    クリティカル処理 
 up(&mutex);
}

を使うべし。