hopperhuang / tech-story

一些技术和一些故事
4 stars 0 forks source link

operating system #16

Open hopperhuang opened 6 years ago

hopperhuang commented 6 years ago

http://iips.icci.edu.iq/images/exam/Abraham-Silberschatz-Operating-System-Concepts---9th2012.12.pdf

hopperhuang commented 6 years ago

Peterson's algorithm 核心思想:

  1. 请求资源时,设置本进程状态为请求资源状态
  2. 请求资源时,设置资源最后请求者为本进程
  3. 当其他进程正在请求资源,且本进程为资源的最后请求者时,本进程进入busy wait 否则,占用资源进入critical section
hopperhuang commented 6 years ago

mutex lock

hopperhuang commented 6 years ago

Semaphores mutex: 信号变量, 初始为1 list: 等待队列 p: 测试信号量, 信号量 -1 ; mutex < 0 则将本进程放入队列 v: 信号量 + 1; mutex <= 0; 唤醒并执行等待队列中其中一个程序 p,v 操作必须时原子操作,禁止中断 p -> critical section -> v

资源 1 p 发布需求 需求 大于 资源 进程进入等待 , 记录需求数量 1 - mutex v 表示完成需求 需求需求数量 -1 1 - (mutex - 1) 表现为 信号量 + 1 ; 完成需求后,仍存在需求,在从队列中找到一个等待执行的程序

hopperhuang commented 6 years ago

reader - writer problems

hopperhuang commented 6 years ago

mutex lock vs semaphores

hopperhuang commented 6 years ago

kernel mode vs user mode

hopperhuang commented 6 years ago
  1. threads
  2. multithreading models
  3. preemptive kernel vs non-preemptive kernels