Skip to main content

13 posts tagged with "default"

View All Tags

范型检查

· One min read
A ClassCastException is thrown if a cast is found at run time to be impermissible.
Some casts result in an error at compile time. Some casts can be proven, at compile time,
always to be correct at run time. For example, it is always correct to convert a value of a
class type to the type of its superclass; such a cast should require no special action at run
time. Finally, some casts cannot be proven to be either always correct or always i

相关阅读:

时间轮算法

· 4 min read

Hashed and Hierarchical Timing Wheels:Data Structures for the Efficient Implementation of a Timer Facility

Conventional algorithms to implement an Operating System timer module take O(n) time to start or main- rain a timer, where n is the number of outstanding timers: this is expensive for large n. This paper be- gins by exploring the relationship between timer algo- rithms, t i m e flow mechanisms used in discrete event simulations, and sorting techniques. Next a timer a l g o r i t h m for small timer intervals is presented t h a t
is similar to the timing wheel technique used in logic sinmlators. By using a circular buffer or timing wheel, it takes O(1) time to start, stop, and m a i n t a i n timers within the range of the wheel. T w o extensions for larger values of the interval are de- scribed. In the first, the timer interval is hashed into a slot on the timing wheel. In the second, a hierarchy of timing wheels with different granularities is used to span a greater range of intervals. T h e performance of these two schemes and various implementation trade- offs are discussed. 传统的操作系统定时器模块的算法复杂度是O(n) ,其中n是定时器的数量:当n很大的时候代价会非常昂贵 。
这篇文章开始探讨定时器算法和时间流机制在离散的事件模拟和排序技术方面的关系.下面的小间隔的定时器算法很类似使用逻辑模拟的时间轮. 通过使用环状缓冲或者时间轮,我们可以在定时器的可维持运行的精度内使用O(1)的时间去开启,结束以及维持定时器 有两个额外的对于大的时间间隔的拓展.第一,定时器的间隔被哈希进去一个时间轮.第二,一个多层级的时间轮保证大于时间间隔的也能有位置存放. 下面会讨论这两张情况和不同实现的平衡.

Our model of a timer module has four component routines: START_TIMER(Interval, Request_ID, Expiry_ Action): The client calls this routine to start a timer that will expire after "Interval" units of time. The client supplies a Request_ID which is used to distinguish this timer from other timers that the client has outstanding. Finally, the client can specify what action must be taken on expiry: for instance, calling a client-specified routine, or setting an event flag. STOP_TIMER(Request_ID): This routine uses its knowledge of the client and Request_ID to locate the timer and stop it. PER_TICK_BOOKKEEPING: Let the granularity of the timer-be T units. Then every T units this routine checks whether any outstanding timers have expired; if so, it calls STOP_TIMER, which in turn calls the next routine. EXPIRY_PROCESSING: This routine does the Expiry_Action specified in the START_TIMER call. The first two routines are activated on client calls while the last two are invoked on timer ticks. The timer is often an external hardware clock. The following two performance measures can be used to choose between the various algorithms described in the rest of this paper. Both of them are parameterized by n, the average (or worst-case) number of outstanding timers. 我们的定时器模块有四个组件模块例程: START_TIMER(Interval, Request_ID, Expiry_Action): 客户端会调用这个例程去启动(注册)一个会在Interval 时间后会过期的定时器.

相关阅读

堆栈

· One min read

在x86_64中,调用栈是从高地址到低地址增长的, %rbp寄存器有两个核心的内容:

  • 0(%rbp)也就是%rbp寄存器指向的寄存器内容,这个指针指向的地址也存着上一个堆栈的%rbp堆栈的地址
  • 8(%rbp)也就是%rbp寄存器存着另外一个存的是返回地址,什么是返回地址?就是指令段的地址

也就是rbp通过寄存器我们可以得到

  • 8(%rbp):上一个堆栈的代码段开始
  • (%rbp): 上一个堆栈的开始

相关阅读

如何写一个正确的代码

· One min read

我们如何写一个正确的代码?

答案是形式化验证,其中一个是霍尔逻辑

举个例子

快速幂
x> 0
x/2/2 ... 必定会归到1 或者0, 所以递归会有限次

快速幂
a^x = floor(a^(x/2))^2 *a^(x%1);
fun(a,x) ={
if(x== 0){
return 1;
}elseif(x== 1){
return a;
}
return fun(a , floor(x/2) )*a^(x%1);
}

数理逻辑

· One min read

数理逻辑我是没有学过的,但是感觉很像编译原理的前端

todolist

· One min read

1 编译原理ssa 2 tensorflow 3 vue原理 4 nlp parser 5 es的search


2020-11-17 我感觉好像什么东西都离不开编译原理,数理逻辑,是我的错觉吗?

双向绑定

· One min read

双向绑定是什么? 这个问题我一直很疑惑,直到我了解了同构和双射

所以双向绑定的本质就是视图和数据同构?

从某种角度上来说,这也是一个米田引理的应用?

可扩展性

· One min read

什么是可扩展性?

我们先看有类型的情况

func(int x, int y){
return x+y
}

这个时候输入的是两个整数返回的是一个整数 x->y->z

可扩展性需要用类型系统或者形式化去描述