Lua笔记

Lua运行结构

  graph LR
  编译器==>PROTO==>虚拟机

描述Lua运行状态,同时可以产生一种面向对象的模拟

struct lua_State {
  CommonHeader;
  lu_byte status;
  lu_byte allowhook;
  unsigned short nci;  /* number of items in 'ci' list */
  StkId top;  /* first free slot in the stack */
  global_State *l_G;
  CallInfo *ci;  /* call info for current function */
  StkId stack_last;  /* end of stack (last element + 1) */
  StkId stack;  /* stack base */
  UpVal *openupval;  /* list of open upvalues in this stack */
  StkId tbclist;  /* list of to-be-closed variables */
  GCObject *gclist;
  struct lua_State *twups;  /* list of threads with open upvalues */
  struct lua_longjmp *errorJmp;  /* current error recover point */
  CallInfo base_ci;  /* CallInfo for first level (C calling Lua) */
  volatile lua_Hook hook;
  ptrdiff_t errfunc;  /* current error handling function (stack index) */
  l_uint32 nCcalls;  /* number of nested (non-yieldable | C)  calls */
  int oldpc;  /* last pc traced */
  int basehookcount;
  int hookcount;
  volatile l_signalT hookmask;
};

lua_state

Linux工具部署功能记录

useradd -m -G users,wheel,audio -s /bin/bash larry
passwd larry
Password: (Enter the password for larry)
Re-enter password: (Re-enter the password to verify)
  1. 更新sync
emerge-webrsync

emerge --sync
  1. 更新软件包
emerge --ask --verbose --update --deep --newuse --getbinpkg @world
  1. 安装软件包
emerge --ask --verbose --getbinpkg 软件包名
  1. 配置key
openssl req -new -nodes -utf8 -sha256 -x509 -outform PEM -out kernel_key.pem -keyout kernel_key.pem

修改make.conf,将路径添加到

完全公平调度器

需要处理的问题?

  1. 如何确定哪个进程可以运行
  2. 进程切换发生后,老的进程去了哪里,新的进程如何变化
  3. PLET实现中,谁负责移动调度实体
static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight *lw)
{
	u64 fact = scale_load_down(weight);
	int shift = WMULT_SHIFT;

	__update_inv_weight(lw);

	if (unlikely(fact >> 32)) {
		while (fact >> 32) {
			fact >>= 1;
			shift--;
		}
	}

	/* hint to use a 32x32->64 mul */
	fact = (u64)(u32)fact * lw->inv_weight;

	while (fact >> 32) {
		fact >>= 1;
		shift--;
	}

	return mul_u64_u32_shr(delta_exec, fact, shift);
}

static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se)
{
	if (unlikely(se->load.weight != NICE_0_LOAD))
		delta = __calc_delta(delta, NICE_0_LOAD, &se->load);

	return delta;
}

最后得到公式

物理页面分配器

linux常用的物理界面分配器的函数是alloc_pages,下面分析是如何实现的.

#define alloc_pages(gfp_mask, order) alloc_pages_node(numa_node_id(), gfp_mask, order)

static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order)
{
	/* Unknown node is current node */
	if (nid < 0)
		nid = numa_node_id();

	return __alloc_pages(gfp_mask, order, node_zonelist(nid, gfp_mask));
}

static inline struct page *__alloc_pages(gfp_t gfp_mask, unsigned int order, struct zonelist *zonelist)
{
	return __alloc_pages_nodemask(gfp_mask, order, zonelist, NULL);
}

此时正式进入函数分析阶段

javascript基础教程

JavaScript是一种运行在浏览器中的解释型的编程语言 JavaScript(JS)是一种具有函数优先特性的轻量级、解释型或者说即时编译型的编程语言。 虽然作为 Web 页面中的脚本语言被人所熟知,但是它也被用到了很多非浏览器环境中, 例如 Node.js、Apache CouchDB、Adobe Acrobat 等。 进一步说,JavaScript 是一种基于原型、多范式、单线程的动态 (en-US)语言, 并且支持面向对象、命令式和声明式(如函数式编程)风格。

CSS3基础教程

Cascading Style Sheets(层叠样式表)

HTML + CSS + JavaScript => 名词 + 形容词 + 动词

CSS可以认为对原始的HTML进行美化

  1. CSS是什么
  2. CSS怎么用
  3. CSS选择器
  4. 美化网页
  5. 盒子模型
  6. 浮动
  7. 定位
  8. 网页动画

美化:字体, 颜色,高度,宽度, 背景图片

STL基础笔记

STL称为标准模板库(Standard Template Library) 广义上可以分为容器,算法,迭代器 容器和算法通过迭代器进行无缝连接 STL几乎所有的代码都采用了函数模版或者类模板