- real time and process time
- real time
Real time is defined as time measured from some fixed point - process time
Process time is defined as the amount of CPU time used by a process(user/systime)
time(2), getrusage(2), clock(3)
- real time
- hardware clock
rtc, software clock based on rtc(by counting timer interrupt, once per jiffy) - software clock, HZ and jiffies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ENCODING_NAME = { | |
1:"SQLITE_UTF8", | |
2:"SQLITE_UTF16LE", | |
3:"SQLITE_UTF16BE" | |
} | |
const PAGE_TYPE = { | |
2:"INTERIOR_INDEX", | |
5:"INTERIOR_TABLE", |
- sysctl -a | egrep retires, retries parameter control tcp close linux ip-sysctl
- when tcp refuses to die
想记录一下有关划分区间的一个有趣问题,来源是 dijkstra 老爷子的 A discipline of programming。
开始之前我们先来看看快排的区间划分。快排的区间划分就是取分点,分点将左右划分为两个区间。比如分点为 pivot,那么一般的,左区间满足小于等于 pivot,右区间满足大于等于 pivot。
比如,考虑区间 [lo, hi],我们对它进行划分。
// lo < hi
func partition(A []int, lo, hi int) int {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
static int ownership = 1; | |
static pthread_mutex_t lock; | |
static void * | |
odd(void *p) { | |
for (;;) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- cooperative task scheduler based on lua coroutine | |
local running_tasklist = {} | |
local iter_index = 0 | |
local function create_task(f, ...) | |
local co = coroutine.create(f) | |
table.insert(running_tasklist, {co = co, args = {...}, start = false}) | |
return co | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"fmt" | |
"strconv" | |
) | |
func sieve(ch chan int, stop chan bool) { | |
nextc := make(chan int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modulus p = 23, base g = 5 | |
secret a = 6, b = 15 | |
public A = g^a mod p = 8, B = g^b mod p = 19 | |
share secret: | |
s = B^a mod p = g^(ab) mod p | |
= A^b mod p = g^(ba) mod p = 2 |
NewerOlder