Thread

Locks Hardware primitives: Test-and-set Pseudo C code: With the help of atomic test-and-set from hardware, simplest lock implementation would be spin-lock Cons: not working on single CPU, since thread will spin on the while loop and thus owner of the lock get no chance to release this lock.

2022-12-31 · 1 min · Rui

File System

Directory just store (filename, inode) pair in it. Hard link is just create another (filename, inode) pair under the directory. Soft link is the third file type beyond file and dir whose content is the linked-to filename, thus soft link has different inode number. See, Inode Given a free disk space, how to design file system on that? Sperate this space into file system blocks Assign data region, inode table, bit map for data region and inode table and super block Data region: User file content...

2 min · Rui

I/O

CPU 和 I/O 设备交互的方式有:polling, Interrupt 快的设备用:polling 慢的设备用:Interrupt Thus, if a device is fast, it may be best to poll; if it is slow, interrupts, which allow overlap, are...

1 min · Rui

Memory

Hardware use base/bound reg to do address translation: if offset < bound: Phy Addr = base + offset Segmentation Each logic segmentation (code, stack and heap) assign a pair of base/bound reg to it and complemented with growing direction and permission: Paging Page table Valid bit: whether this translation is valid or not. For example for unallocated page is not valid translation Protection bit: whether the process has the priviledge to access this page...

1 min · Rui

Process

fork() 创建一个和父进程一样的子进程,然后在子进程中return 0 父进程中return子进程的pid exec()覆写当前进程的代码段,堆栈等,成功...

1 min · Rui