Access Right
1 | touch tree |
1 | $ touch tree |
引用自wiki
In computer science, the thundering herd problem occurs when a large number of processes waiting for an event are awoken when that event occurs, but only one process is able to proceed at a time. After the processes wake up, they all demand the resource and a decision must be made as to which process can continue. After the decision is made, the remaining processes are put back to sleep, only to all wake up again to request access to the resource.
This occurs repeatedly, until there are no more processes to be woken up. Because all the processes use system resources upon waking, it is more efficient if only one process is woken up at a time.
This may render the computer unusable, but it can also be used as a technique if there is no other way to decide which process should continue (for example when programming with semaphores).
引用自 wiki
A bracket expression. Matches a single character that is contained within the brackets. For example, [abc] matches “a”, “b”, or “c”. [a-z] specifies a range which matches any lowercase letter from “a” to “z”. These forms can be mixed: [abcx-z] matches “a”, “b”, “c”, “x”, “y”, or “z”, as does [a-cx-z].
The - character is treated as a literal character if it is the last or the first (after the ^, if present) character within the brackets: [abc-], [-abc]. Note that backslash escapes are not allowed. The ] character can be included in a bracket expression if it is the first (after the ^) character: []abc].
说的很明白了不翻译了,重点:
在Google搜索“php 抽奖”, 通篇最为常见的算法如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<?php
// “经典抽奖算法”
function rand2($arr)
{
$sum = array_sum($arr);
foreach($arr as $key => $value)
{
$ret = rand(0, $sum * MAX - 1);
if ($ret < $value * MAX)
return $key;
else
$sum -= $value;
}
}
?>
- 存储数组的链表
- 每个链表元素 ngx_list_part_t 又是一个数组,拥有连续的内存