background picture of the home page

Hi,Friend

slab分配器(深入理解linux内核)

引子 前文介绍了使用为了解决外部碎片,使用Buddy System进行连续内存页面的分配,但对于使用内存的程序而言,Buddy System分配的内存粒度过大,假如我们需要动态申请一个内核结构体(占 20 字节),若仍然分配一页内存,这将严重浪费内存。那么该如何分配呢?slab 分配器专为小内存分配

thumbnail of the cover of the post

伙伴系统(Buddy System)

引子 在linux的内存管理中,由于不同程序频繁的使用和释放内存,必然会导致内存碎片的产生。 所谓内存碎片就是内存被分割成很小很小的一些块,这些块虽然是空闲的,但是却小到无法使用。随着申请和释放次数的增加,内存将变得越来越不连续。最后,整个内存将只剩下碎片,即使有足够的空闲页框可以满足请求,但要分配

thumbnail of the cover of the post

c++中几种swap

 在c与c++中,有多种办法可以通过函数交换传入的两数的值,但有容易有一些问题产生,因而本文将几种交换方式及容易出错的点进行了分类。 1.传引用 这是c++中最常见方式 如下: int swap1 (int &a,int &b) { int c; c=a;    a=b;   

thumbnail of the cover of the post

Vue源码阅读--数组方法的响应式包装和实现

数组原生的方法产生的数据更新原本来说,是不会在使用Vue时发生响应式变化的,而我i们使用push,pop等方法实际上是因为Vue对这些方法做了一层封装,其基本的实现路径如下: 首先,包装监听的过程位于源代码文件夹中的\src\core\observer\array.js部分: 1 import {

thumbnail of the cover of the post

1018 Public Bike Management

There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any s

thumbnail of the cover of the post

1020 Tree Traversals

Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou

thumbnail of the cover of the post

1063 Set Similarity

Given two sets of integers, the similarity of the sets is defined to be /, where Nc is the number of distinct common numbers shared by the two sets, a

thumbnail of the cover of the post

1108 Finding Average

The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input n

thumbnail of the cover of the post

1139 First Contact

Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a g

thumbnail of the cover of the post