Day 3 Linux kernel unshare

Day 3 Linux kernel unshare

Talk is cheap. Show me the code.————Linus Torvalds(Linux之父)

Most legacy operating system kernels support an abstraction of threads as multiple execution contexts within a process.
很多老旧的操作系统内核以这样的方式来支持线程:它们把线程抽象成了同一进程内的多个执行上下文。

These kernels provide special resources and mechanisms to maintain these “threads”.
这些系统内核提供了特殊的资源和管理机制来支持这类线程。

The Linux kernel, in a clever and simple manner, does not make distinction between processes and “threads”.
而Linux内核,则采用了一种聪明而且简单的方式——在内核层面上,它并不区分进程和线程。

The kernel allows processes to share resources and thus they can achieve legacythreads” behavior without requiring additional data structures and mechanisms in the kernel.
Linux内核允许多条进程共享资源。这样做的好处在于,即使内核不再提供额外的数据结构和管理机制,和传统线程类似的行为也能被实现出来。

The power of implementing threads in this manner comes not only from its simplicity but also from allowing application programmers to work outside the confinement of all-or-nothing shared resources of legacy threads.
以这样的实现方式来支持线程,不仅简单,而且也可以帮助程序员们摆脱曾经让他们感到烦恼的一个限制:在传统的线程模型中,要么就不能共享资源,要么就得全局共享资源。

On Linux, at the time of thread creation using the clone system call, applications can selectively choose which resources to share between threads.
在Linux中,程序在使用clone这个系统指令去创建线程时,可以选择性地指定哪部分资源会被其他线程所共享,而无需将所有资源都共享出去。

unshare() system call adds a primitive to the Linux thread model that allows threads to selectivelyunshare’ any resources that were being shared at the time of their creation.
unshare这个系统指令,为Linux的线程模型增加了一个基本功能:即便一些资源在线程创建时被设置为可共享了,也可以使用unshare指令将这些资源重新收归私有。

OSI and TCP/IP are the most used models to abstract the computer network.
OSI和TCP/IP是在抽象计算机网络时最常用的两种模型。

OSI, the theoretically better abstraction of the network model, failed to be widely adopted due to its complexity.
OSI,这种在理论上看似更优的网络模型的抽象方式,由于过于复杂而没有被工业界大规模采用。

本文选自:
https://www.kernel.org/doc/html/latest/userspace-api/unshare.html

生词 音标 释义
legacy [ˈlɛɡəsi] n. 遗产
kernel ['kɜ:nəl] n. 内核
abstraction [æbˈstrækʃən] n. 抽象
thread [θrɛd] n. 线程
execution context 执行上下文
resource [ˈri:sɔ:rs] n. 资源
mechanism [ˈmɛkəˌnɪzəm] n. 机制
in a manner 以某种方式
distinction [dɪˈstɪŋkʃən] n. 区别
allow [əˈlaʊ] v. 允许
share resource 共享资源
require [rɪˈkwaɪr] v. 需要
additional [ə'dɪʃənl] adj. 附加的
stable [ˈstebəl] adj. 稳定的
confinement [kənˈfaɪnmənt] n. 限制
all-or-nothing adj. 不则全无的
selectively [sɪ'lektɪvlɪ] adv. 选择性地
unshare v. 不分享
primitive [ˈprɪmɪtɪv] adj. 原始的
adopt [əˈdɑ:pt] v. 采取
complexity [kəmˈplɛksɪti] n. 复杂性
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,026评论 19 139
  • 我们都知道,现在是一个分享经济的时代,既然是分享,那肯定就要谈到分销。因为分销,可以让平台粉丝迅速裂变倍增哦,包括...
    大鸭梨儿阅读 149评论 0 0
  • 前言 最先接触编程的知识是在大学里面,大学里面学了一些基础的知识,c语言,java语言,单片机的汇编语言等;大学毕...
    oceanfive阅读 3,167评论 0 7
  • 现在的幸福是什么? 呵呵,眼前的幸福恐怕是可以去当个客户经理? 可以在东边买个房子,只要8000一平就好? 手机的...
    恋恋风尘_阅读 247评论 0 0
  • 此刻,我蹲在凌乱房间的地上 电扇吱呀作响 窗外雾蒙蒙的天闷热的就要拧出水来 知了不时的在叫 似乎是要告诉你 夏天才...
    呆丫阅读 383评论 0 3