美文网首页
Day 3 Linux kernel unshare

Day 3 Linux kernel unshare

作者: mocobk | 来源:发表于2018-07-13 12:26 被阅读0次

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. 复杂性

相关文章

网友评论

      本文标题:Day 3 Linux kernel unshare

      本文链接:https://www.haomeiwen.com/subject/woyjpftx.html