linux根文件系统挂载
由bootload进入linux后由head.s进入了start_kernel了.
asmlinkage void __init start_kernel(void)
{
char * command_line;
extern struct kernel_param __start___param[], __stop___param[];
………………..
setup_arch(&command_line);
………….
………..
vfs_caches_init(num_physpages); ………….
…………...
rest_init();
}
重要函数解释
1.Setup_arch是解释bootloader传过来的参数,并附相关参数。
void __init setup_arch(char **cmdline_p)
{
struct tag *tags = (struct tag *)&init_tags;
struct machine_desc *mdesc;
char *from = default_command_line;
setup_processor();
mdesc = setup_machine(machine_arch_type);
machine_name = mdesc->name;
if (mdesc->soft_reboot)
reboot_setup("s");
if (mdesc->boot_params)
tags = phys_to_virt(mdesc->boot_params);
/*
* If we have the old style parameters, convert them to
* a tag list.
*/
&nb
相关文档:
//
同步问题:
对共享数据的访问,需要同步,互斥。
在中断,抢占,多CPU,多线程 环境下尤其重要。
同步分为: 阻塞同步,非阻塞同步
阻塞同步有许多实现方式了:mutex, semaphore. 阻塞同步使用不当就可能造成死锁,活锁,优先级反转。
非阻塞同步:(现在流行三种)
wait free 很难实现,思想是本线程有限步就 ......
/*
* linux/fs/char_dev.c
*
* (C) 1991 Linus Torvalds
*/
#include <errno.h>
#include <sys/types.h> // 定义了基本的系统数据类型
#include <linux/sched.h>
#include <linux/kernel.h> // 含有一些内核常用函数的原形定义
#include < ......
/*
* buffer.c 程序用于对高速缓冲区(池)进行操作和管理。高速缓冲
* 区位于内核代码和主内存区之间。
*
* |---|---|------------------|---------------------|-------------------|
* | | | * * * | &nbs ......
/*
* linux/fs/file_dev.c
*
* (C) 1991 Linus Torvalds
*/
#include <errno.h>
#include <fcntl.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <asm/segment.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#defi ......