BSD代码分析

发布于 2008-05-22 21:55:04
分析BSD内核代码的流水帐贴,相应的部分不断更新完善

====
src\sys\kern目录文件分类
bufq_disksort.c -- Seek sort for disks.
bufq_fcfs.c -- First-come first-served sort for disks.

core_elf32.c -- Support for the Elf32/Elf64(64?) core file format.
core_netbsd.c -- Support for the historic NetBSD core file format.
exec_aout.c --
exec_conf.c --
exec_elf32.c --
exec_script.c --
exec_subr.c --

查看更多

关注者
0
被浏览
7.5k
8 个回答
layer2
layer2 2008-05-25
the important files in the kern as below(可能有不精确的,代后会更正 ):
bufq_disksort.c --- Seek sort for disks
bufq_fcfs.c --- First-come first-served sort for disks
cnmagic.c --- magic string
core_elf32.c --- Support for the Elf32/Elf64 core file format
core_elf64.c --- Support for the Elf32/Elf64 core file format
core_netbsd.c --- Support for the historic NetBSD core file format
exec_aout.c --- Support for out executable format
exec_conf.c --- Build in functions of supporting xx executable format.exec switch
exec_elf32.c --- Support for elf32 executable format
exec_elf64.c --- Support for elf64 executable format
exec_script.c --- support for script executable format
exec_subr.c --- vm function support for exec_xx.c(setup the virtual memory space and to load the program code and data sections)
init_main.c --- System startup; initialize the world, create process 0, mount root filesystem, and fork to create init and pagedaemon. Most of the hard work is done in the lower-level initialization routines including startup(), which does memory initialization and autoconfiguration.
init_sysctl.c --- init system control
init_sysent.c --- System call switch table.
kern_acct.c --- simplify accounting operations, this mechanism should be replaced by one in which an accounting log file
kern_auth.c --- Authorize a request by credential
kern_clock.c --- Clock handling routines
kern_descrip.c --- Descriptor management.
kern_event.c --- An array containing for each system call an entry with the number of arguments, the size of the system call arguments structure, and a pointer to the function that implements the system call in the kernel
kern_exec.c --- entry of execve switch and init execve switchs
kern_exit.c --- a suit of exiting function about kern
kern_fork.c --- system fork
kern_kthread.c --- functions about kthread creating and destroying
kern_ktrace.c --- operations to ktrace system call
kern_lock.c --- kernel lock
kern_lwp.c --- Support a light-weight process
kern_malloc.c --- Functions about kernel memory malloc and free
kern_ntptime.c --- These routines constitute the Network Time Protocol (NTP) interfaces for user and daemon application programs
kern_physio.c --- Raw Devices and Physical I/O
kern_proc.c --- management about process
kern_prot.c --- System calls related to processes and protection
kern_ras.c --- restartable atomic sequences
kern_resource.c --- Resource controls and accounting.
kern_sa.c --- the scheduler activation implementation that permits efficent management of concurrency
kern_sig.c --- kernel signal
kern_subr.c --- kern subroutines including hook, trace ,device ..
kern_synch.c --- Scheduling algorithms
kern_sysctl.c --- kern system control,sysctl system call.
kern_tc.c --- kern timer counter
kern_time.c --- Time of day and interval timer support.
kern_timeout.c --- Timeouts are kept in a hierarchical timing wheel. The c_time is the value of the global variable ""hardclock_ticks"" when the timeout should be called.
kern_todr.c --- time-of-day clock support
kern_uuid.c --- support uuid (Universally Unique IDentifier)
kern_xxx.c --- system reboot (the reason that the name is XXX ??)
subr_autoconf.c --- Autoconfiguration subroutines.
subr_blist.c --- Bitmap allocator/deallocator, using a radix tree with hinting
subr_bufq.c --- support device buffer queue
subr_callback.c --- support callback
subr_devsw.c --- New device switch framework is developing. So debug options are always turned on.
subr_disk.c --- subroutine about disk
subr_evcnt.c --- generic event counter framework
subr_extent.c --- General purpose extent manager.
subr_iostat.c --- support the i/o statistics
subr_kmem.c --- allocator of kernel wired memory.
subr_log.c --- Error log buffer for kernel printf's.
subr_once.c --- support Running a function exactly once
subr_optstr.c --- The options string management functions
subr_pool.c --- Pool resource management utility.
subr_prf.c --- printf
subr_prof.c --- system profiling
subr_specificdata.c --- support specificdata
subr_userconf.c --- user conf function suit
subr_vmem.c --- Magazines and Vmem: Extending the Slab Allocator to Many CPUs and Arbitrary Resources
subr_workqueue.c --- support work queue ( Enqueue the work wk into the workqueue wq)
subr_xxx.c --- Miscellaneous trivial functions, including many that are often inline-expanded or done in assembler.
sys_generic.c --- generic functions
sys_pipe.c --- This file contains a high-performance replacement for the socket-based pipes scheme originally used in FreeBSD/4.4Lite.
sys_pmc.c --- support performance-monitoring counter
sys_process.c --- support process trace
sys_socket.c --- support socket
syscalls.c --- system call
sysv_ipc.c --- support ipc
sysv_msg.c --- support msg
sysv_sem.c --- suppoort sem
sysv_shm.c --- support shm
tty.c --- support tty
tty_bsdpty.c --- support tty
tty_conf.c --- support tty
tty_ptm.c --- pty multiplexor driver
tty_pty.c --- Pseudo-teletype Driver
tty_subr.c --- support tty
tty_tty.c --- Indirect driver for controlling tty.
uipc_domain.c --- network domain management
uipc_mbuf.c --- memory management in the kernel IPC subsystem
uipc_mbuf2.c --- memory management in the kernel IPC subsystem
uipc_proto.c --- Definitions of protocols supported in the UNIX domain
uipc_sem.c --- uipc semphore for socket
uipc_socket.c --- Socket operation routines. These routines are called by the routines in sys_socket.c or from a system process, and implement the semantics of socket operations by switching out to the protocol specific routines.
uipc_socket2.c --- Primitive routines for operating on sockets and socket buffers
uipc_syscalls.c --- System call interface to the socket abstraction.
uipc_usrreq.c --- UNIX domain sockets
vfs_bio.c --- support vfs, realization of the buffer zone management
vfs_cache.c --- vfs name cache
vfs_getcwd.c --- Gets the current working directory
vfs_hooks.c --- VFS hooks.
vfs_init.c --- vfs init, Allocate and fill in operations vectors.
vfs_lockf.c --- record locking on (vf)files
vfs_lookup.c --- lookup function
vfs_subr.c --- External virtual filesystem routines
vfs_syscalls.c --- Virtual File System System Calls
vfs_vnops.c --- vnode operations
vfs_xattr.c --- VFS extended attribute support.
vnode_if.c --- Vnode Operations
bernard
bernard 2008-05-25
subr_vmem.c --- Magazines and Vmem: Extending the Slab Allocator to Many CPUs and Arbitrary Resources
其中说到的论文:
Magazines and Vmem: Extending the Slab Allocator to Many CPUs and Arbitrary Resources
http://www.usenix.org/event/usenix01/fu ... onwick.pdf

具体subr_vmem.c是干什么的还得仔细看看。
bernard
bernard 2008-06-06
vmem : fast, general resource allocation
The slab allocator caches relatively small objects and relies on a more general-purpose backing store to provide slabs and satisfy large allocations. vmem is a new resource allocator that can manage arbitrary sets of integers - anything from virtual memory addresses to minor device numbers to process IDs. vmem acts as a universal backing store for the slab allocator, and provides resource allocation problems. vmem appears to be the first resource allocator that can satisfy allocations and frees of any size in guaranteed constant time.

vmem :快速,通用的资源分配器
slab分配器缓存相对较小的物体,并依赖于一个更通用的后端存储以提供片及满足大内存块分配。 vmem是一种新的资源配置器,可以管理任意整数-任何从虚存地址,次编号的设备号,到进程ID等整数。 vmem能够为slab分配器提供一个统一的存储后端,并解决资源分配的问题。vmem几乎是第一个保证在常数时间内满足任何大小分配和释放的资源配置器。
liyun
liyun 2010-08-28
我进来没看懂一半,英语不好. [s:182]
为什么会这样呢?难道发贴的人中文不好,所以写不了中文???????????????开个玩笑! [s:186]

在中国会单片机编程的,但又不精通英文的不在少数?
[s:195] 难道RT-Thread的作者们想设一道门槛,滤掉我们这群人?

为了让更多的人了解RT-Thread,请使用中文!!!!!!
aozima
aozima 2010-08-28
我进来没看懂一半,英语不好. [s:182]
为什么会这样呢?难道发贴的人中文不好,所以写不了中文???????????????开个玩笑! [s:186]

在中国会单片机编程的,但又不精通英文的不在少数?
[s:195] 难道RT-Thread的作者们想设一道门槛,滤掉我们这群人?

为了让更多的人了解RT-Thread,请使用中文!!!!!!

开始跟你一样的想法...
后来发现从技术角度上讲.只有认英文才能看到好的代码.
不然.你先让BSD的代码全写成中文的.. [s:175]
bernard
bernard 2010-08-29
我进来没看懂一半,英语不好. [s:182]
为什么会这样呢?难道发贴的人中文不好,所以写不了中文???????????????开个玩笑! [s:186]

在中国会单片机编程的,但又不精通英文的不在少数?
[s:195] 难道RT-Thread的作者们想设一道门槛,滤掉我们这群人?

为了让更多的人了解RT-Thread,请使用中文!!!!!!


难道ls没见到过《RT-Thread编程指南》的那本300多页的电子书?
mbbill
mbbill 2010-08-30
我进来没看懂一半,英语不好. [s:182]
为什么会这样呢?难道发贴的人中文不好,所以写不了中文???????????????开个玩笑! [s:186]

在中国会单片机编程的,但又不精通英文的不在少数?
[s:195] 难道RT-Thread的作者们想设一道门槛,滤掉我们这群人?

为了让更多的人了解RT-Thread,请使用中文!!!!!!


这问号叹号用的。。。。看得我心惊肉跳的。。。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友