This repository has been archived by the owner on Dec 29, 2023. It is now read-only.
forked from swetland/xv6
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
tyfkda edited this page Dec 13, 2018
·
18 revisions
- Block size(
BSIZE
): 512B - inodestart = 32, ninodes = 200
- inode info: 0x4000~ (= inodestart * BSIZE)
- bmapstart: 57, size=1 (= FSSIZE / (BSIZE * 8) + 1)
- freeblock: 58~
-
proc.c: userinit() -> Spawn "initcode" proc
-
initcode.S -> Exec "init"
-
init.c: main() -> Exec "sh" (Loop forever)
-
sh.c: main() : Shell process
- Timer interrupt (100ms)
- trap.c
trap()
,case T_IRQ0 + IRQ_TIMER:
- proc.c
yield()
- proc.c
shed()
- swtch.S
swtch
Kernel:
- sysfile.c: sys_write()
- file.c: filewrite()
- fs.c: writei() =>
return devsw[ip->major].write(ip, src, n);
- console.c: consoleinit() =>
devsw[1].write = consolewrite
- console.c: consoleinit() =>
- console.c: consolewrite()
- console.c: consputc()
- uart.c: uartputc()
- console.c: cgaputc()
Creation:
- User space:
- usys.S: pipe(int*)
- Kernel space:
- vectors.S: vector64 (T_SYSCALL=64)
- trapasm.S: alltraps
- trap.c: trap()
- syscall.c: syscall()
- sysfile.c: sys_pipe()
- pipe.c: pipealloc()
- filealloc x 2, 1 for read, 1 for write
- kalloc x 1, used to keep pipe struct.
Write:
- sysfile.c: sys_write()
- file.c: filewrite()
- pipe.c: pipewrite()
Read:
- sysfile.c: sys_read()
- file.c: fileread()
- pipe.c: piperead()
- Sleep/wakeup mechanism
- Fork/exec mechanism
- Support
>>
in shell- Add file append mode
- Add mtime to file info
- RTC
- Analyze ELF execution sequence (How to allocate memory, etc.)
- Use .text, .rodata, .data, .bss sections
- POSIX
$ memmap
execelf: /bin/memmap
vaddr=1000, memsz=2c68, filesz=1c31, sz=3c68
sz=3c68
sp=6000
main: 0x1046
bss: 0x2c40
const_data: 0x2660
rw_data: 0x2b60
stack: 0x5f58
sbrk: 0x6000
- User stack:
1
xPGSIZE
=4096
- elfの段階でプログラム、定数データ、読み書きデータ、未初期化領域もすべて1つの領域になっていて、連続したメモリ領域に確保・読み込まれる。
その直後に1ページのアクセス不可領域、そしてスタック領域が確保される。
Address | Entity |
---|---|
0x80100000- | Kernel program |
Virtual Address | Entity |
---|---|
0x00001000- | User program |
data, bss | |
heap | |
0x10000000- | User stack |
.