10/12
2017

继承结构

06/07
2017

1. 进程与线程的本质区别:

http://lkml.iu.edu/hypermail/linux/kernel/9608/0191.html

Both threads and processes are really just one thing: a “context of execution”. Trying to artificially distinguish different cases is just self-limiting. A “context of execution”, hereby called COE, is just the conglomerate of all the state of that COE. That state includes things like CPU state (registers etc), MMU state (page mappings), permission state (uid, gid) and various “communication states” (open files, signal handlers etc). Traditionally, the difference between a “thread” and a “process” has been mainly that a threads has CPU state (+ possibly some other minimal state), while all the other context comes from the process.

其实进程和线程在操作系统上都是一个东西,叫做context of execution,进程与线程的区别就是:

  1. 进程:
    • CPU state: registers etc
    • MMU state: page mappings,记录当前进程的虚拟内存地址到物理内存地址的映射的信息。
    • permission state: uid, gid
    • various “communication states”: open files, signal handlers etc
  2. 线程:
    • CPU state: registers
      • possibly some other minial state
    • all others: shared from process

可以看到,进程和线程都是COE,但进程包含所有的信息,包括CPU、内存、分页信息(MMU)等;而线程是包含自己的CPU信息(可以抽象理解为栈信息),内存信息以及地址分页信息等都是共享进程的。

05/11
2017

1. 背景

背景就是写一个h5,大概的结构就是:

--index.html
    -- main.js(一堆js,以main.js做入口)
    -- main.less(一堆less,以main.less做入口)
    -- assets/xxx.jpg|png

要求是:

  1. 将所有的styles打包到一个bundle.css,并计算文件的md5生成[hash].css,自动更新index.html的样式引用
  2. 将所有的js打包到一个bundle.js,并计算文件的md5生成[hash].js,自动更新到index.html的js引用
  3. 将其他所有引用的图片资源等,assets目录下的,计算资源的md5,更新到index.html、main.css的引用中。

    其实也有对更新main.js中assets路径的资源字符串的引用更新的需求,此需求请自写loader,处理这个

  4. 将更新后的index.html也输出
05/04
2017

概述

最近因知乎的某个问题,再次想探索一下 JS 中关于 let/const var 在规范中的区别。

1. 区别

  • let/const都属于Let and Const Declarations,往execute context的LexicalEnvironment添加identifier,并赋值,它在声明之前是无法访问到的。
  • var属于Variable Statement,往execute context的VariableEnvironment里面添加identifier,并赋值,它的声明是在execute context创建的时候,可以在var statement访问,但是undefined。

通常一个execute context的LexicalEnvironment 和 VariableEnvironment是same value,一次可以经常看到let a = 1; var a = 1;第二个var就会抛错。

04/07
2017

目录

  1. 介绍
  2. instrument
  3. cover
  4. node vs browser