Week 49, 2019
挑了一本上周下载的 Operating Systems: Three easy pieces ^[http://pages.cs.wisc.edu/~remzi/OSTEP/]. 来读,这次尝试不用翻译阅读,起初看地比较吃力,后来觉得越来越顺畅了。这本书从虚拟化、并发和持久化三个方面介绍,这种结构更容易把知识打穿,也是我选择这本书的原因。读了7个 chapter 也发现了几个问题,和群里的朋友们探讨了一下:
Q1: 获取系统时间(gettimeofday())是否会进行系统调用?
- Switching Between Processes
- A Non-Cooperative Approach: The OS Takes Control
- A timer device can be programmed to raise an interrupt every so many milliseconds; when the interrupt is raised, the currently running process is halted, and a pre-configured interrupt handler in the OS runs. At this point, the OS has regained control of the CPU, and thus can do what it pleases: stop the current process, and start a different one.
- A Non-Cooperative Approach: The OS Takes Control
思考: Timer 用于进程切换,此外系统的时间也由它进行维护,那么每次获取系统时间是否会进行系统调用?
A: 每个 OS 有不同的实现,对于 OSX 来说,不需要。commpage 会异步地从内核更新包括时间的地址空间。
Briefly, it is a special area of kernel memory that is mapped into the last eight pages of the address space of every process. Among other things, it contains time values that are “updated asynchronously from the kernel and read atomically from user space, leading to occasional failures in reading”.^[https://stackoverflow.com/questions/40967594/does-gettimeofday-on-macos-use-a-system-call]
Q2: 为什么 UNIX 使用 fork-exec 的形式创建进程,而不是直接 create
A: 简单来说,采用 fork-exec 可以根据需求组合成不同的应用,而且对于 UNIX 中管道操作较为友好。
- Switching Between Processes
毕业体检也完成了,不得不说我校的医生专业能力特别强:不需要仪器直接就能测出血压…
庆余年开播了,不得不说我实在不能接受男主角的选角😓
leetcode 开始二刷,7天做了9道题。状态就是:easy 秒,medium 在纸上画画能出来, hard 看了题解也得想半天🤣
初中同学来大连看演出,陪他逛了逛。大连这个季节加上下雨,星海广场上连个人都没有。
下了三天自走棋,果然还是游戏好玩。
桌面又收拾了一下,电脑显示器和 pad 又重新布局,感觉还行吧。(图里有本书是彩蛋😆)
29 号过生日来着。22岁了反倒没有什么生日的感觉,和往常日子一样看看书、写会儿代码就过去了。
找老师谈了谈毕设的事情,结论就是只要工作量足够,随便写什么,到时候题目再改。