OS
2016-12-29 09:56:25 0 举报
AI智能生成
操作系统(OS)是管理计算机硬件与软件资源的计算机程序,同时也是计算机系统的内核与基石。它负责处理和控制计算机系统中的各种操作,包括处理器管理、内存管理、设备管理和文件管理等。通过提供一个统一的接口,操作系统使得应用程序可以高效地运行在计算机硬件上,而无需直接与底层硬件交互。常见的操作系统有Windows、macOS、Linux等。操作系统的发展也推动了计算机技术的不断进步,为用户提供了更加便捷、高效的计算环境。
作者其他创作
大纲/内容
第十章:文件
文件是什么
Contiguous logical address space
sequence of bits bytes lines or records
读写顺序
sequential access
random access
Directory Structure
single-level directory
naming problem
grouping problem
二级文件
tree structure
Acyclic-Graph Directories
mount
会把原来的内容隐藏
可循环mount
mount /dev/dsk /users
Access Lists and Groups
chmod
第十一章:文件系统
Data Structure
打开文件、读取文件
open
user-space->syscall
Kernel memory->Dentry
->secondary storage->inode
read
user space
>index(per-process open file table)
>system-wide open-file table
>data blocks(secondary storage)
Virtual File System
file-system interface
VFS interface 统一接口
local file system type1
local file system type2
remote file system type1
Allocation Methods
contiguous allocation
注意block size(一般为4K)
支持很快的随机读写和顺序读写
缺点:新文件必须找到连续那么大的block
改进:Extent-based Allocation
LA/512
Linked allocation
block的第一个字指向下一个block
不支持随机读写
LA/511
Indexed allocation
专门用一个block存所有指针
支持文件大小有限,512*512
扩充支持
形成链表,组合在一起使用,index指向下一个block
降低随机读写速度
可以支持任意长度
LA/(512*511)得出Q1,R1
R1/512得出Q2,R2
Two level index allocation
maximum file size is 512^3
LA/512^level(max3)->Q1,R1
R1/512->Q2,R2
LA/512
unix disk allocation
看图
inode
计算可支持最大的文件
Free space management
Bit vector(n blocks)
需要额外内存空间资源
算法简单
如何寻找连续空闲块
Block/Page Buffer
Dentry and Inode
Dentry(Name+Inode)
see figure 1
每次打开文件都有一个Dentry
Inode只有一个(里面就是内容)
第十二章:Mass Storage System
Disk
track
从外往里算0->n
MBR,写在0号track的0号sector,512字节
400多个字节boot code
64字节 partition table
2个特殊字节
sector
header+data+trailer
cylinder
platter
spindle
arm assembly
Access Cost
seek time(track)
优化,让请求分布合理
FCFS
SSTF
SCAN
LOOK
C-LOOK
C-SCAN with Look
rotational delay(sector)
transfer time(moving data)很小
Raid 0-6
Raid0
最少磁盘数量2
可支持错误代价0
Raid1
mirror disks
最少磁盘数量2,一个为备份
Raid2
memory-style error-correcting codes
Raid3
一块存奇偶校验码
Raid4
block-interleaved parity
Raid 5
奇偶校验码分磁盘储存
Raid 6
多个奇偶校验码
第十三章:I/O Systems
PCI Bus
Device Ports
I/O Port Register
Data-in
Data-out
Status
Control
查询方法
Polling
command-ready
busy
wait
忙等待
Interruption
CPU interrupt-request line
interrupt handler
maskable
Direct Memory Access
常见的I/O分类
Device Drivers
内核中
第六章:进程同步
例子
生产者消费者问题
Bounded Buffer Problem
共享内存数据:mutex
互相唤醒信号量:几个进程几个信号量(成对)
要点:信号量定义、成对出现、初始值
Readers-Writer Probelm
Writer:Mutex,判断有无Reader
Reader
判断是否是第一个Reader
wait rw_mutex
判断是否是最后一个Reader
signal(rw_mutex)
Dining-Philosophers Problem
wait 左筷子
wait 右筷子
死锁
Monitor
Condition Variable
实际问题——数据库:Transaction
start,commit
ACID
可序列化
不存在资源竞争,交换后序列化执行
Timestamp Scheduling
Critical Section
Mutual Exclusion
Progress
Bounded Waiting
保证只有一个进程进入
Synchronization Hardware
所有进程共享一个lock,进入进程后锁住
compare_and_swap
缺点
修改体系架构
只允许一个进程进入
软件:
Semaphore
普通,忙等待
Implementation
struct{int value; struct process *list}
第七章:DeadLock
产生要素
Mutual Exclusion 排他访问
Hold and Wait 资源等待
No Preemption 不可强制释放资源
Circular Wait 循环等待
Resource-Allocation Graph
环不一定有死锁,判断Process是否可以一次运行完
Prevention
Mutual Exclusion
Shared resources
Hold and Wait
两阶段上锁协议
No Preemption
非抢占性,KILL
Circular Wait
资源编号,强制先拿编号低的锁,证明
Avoidance
safe状态
存在safe sequence{P0-PN},可安全依次执行
safe 矩阵
safety algorithm
Bankers algorithm
维护矩阵浪费资源
Detection
进程、资源图
进程等待图
Recovery
Process Termination
Terminate all processes
Terminate process one by one
Resource Preemption
Victim
Roll Back
第八章:Memory
Basic Idea
CPU发出指令:虚拟地址
通过MMU转换为物理地址
CPU->address->[base,base+limit)->memory
Address Binding
虚地址转换为实地址
Dynamic Loading and Linking
Swapping
两倍内存大小的swap区域
Memory Allocation
子主题
best fit
worst fit
Paging
page number->frame number
page table:valid number
page size
page allocation
TLB: translation look-aside buffer
时间计算
structure of paging
hierarchy paging
logical-physical
hash paging
???
inverted paging
segmentation
32bit-logical address
segments(10bit) + page(12bit) + offset(10bit)
32bit-physical address
seg[s].base->page[p].frame + i
第九章:Virtual Memory
demand paging
swap
slot
page fault
reference
软件中断->Trap CR2
page is on backing store
bring in missing page to physical memory
reset page table
restart instruction
Copy on write
page replacement
FIFO
Optimal
LRU
second-chance(clock) page-replacement algorithm
Thrashing
working set
Memory Mapper File
Kernel Memory Allocation
Slab Allocation
0 条评论
下一页