随笔分类 -  ALGO

摘要:SpinLock 自旋锁spinlock 用于CPU同步, 它的实现是基于CPU锁定数据总线的指令.当某个CPU锁住数据总线后, 它读一个内存单元(spinlock_t)来判断这个spinlock 是否已经被别的CPU锁住.如果否, 它写进一个特定值, 表示锁定成功, 然后返回.如果是, 它会重复以... 阅读全文
posted @ 2014-08-17 00:01 IAmAProgrammer 编辑
摘要:#include #include//定义PID 的结构体 struct _pid{ int pv; // integer that contains the process value 过程量 int sp; // integer that contains... 阅读全文
posted @ 2013-09-17 13:40 IAmAProgrammer 编辑
摘要:https://zh.wikipedia.org/wiki/%E9%80%92%E5%BD%92递归(英语:Recursion),又译为递回,在数学与计算机科学中,是指在函数的定义中使用函数自身的方法。递归一词还较常用于描述以自相似方法重复事物的过程。例如,当两面镜子相互之间近似平行时,镜中嵌套的图像是以无限递归的形式出现的。语言例子从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?“从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?‘从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?……’”以下是另一个可能更有利于 阅读全文
posted @ 2013-05-27 20:13 IAmAProgrammer 编辑
摘要:http://c2.com/cgi/wiki?TailRecursionRecursive procedures call themselves to work towards a solution to a problem. In simple implementations this balloons the stack as the nesting gets deeper and deeper, reaches the solution, then returns through all of the stack frames. This waste is a common compla 阅读全文
posted @ 2013-05-27 19:06 IAmAProgrammer 编辑
摘要:loop [lu:p]、iterate ['itəreit]、traversal [træ'vɜ:sl]和recursion [rɪˈkɜ:ʃn]分别翻译为:循环、迭代、遍历和递归。循环是计算机科学运算领域的用语,也是一种常见的控制流程。循环是一段在程序中只出现一次,但可能会连续运行多次的代码。循环中的代码会运行特定的次数,或者是运行到特定条件成立时退出循环,或者是针对某一集合中的所有项目都运行一次。在计算机科学中,For循环(英语:For loop)是一种编程语言的迭代陈述,能够让程式码反复的执行。它跟其他的循环,如while循环,最大的不同,是它拥有一个循环计数器 阅读全文
posted @ 2013-05-27 17:19 IAmAProgrammer 编辑
摘要:http://aggregate.org/MAGIC/The Aggregate Magic AlgorithmsThere are lots of people and places that create and collect algorithms of all types (hereare a few WWW sites). Unfortunately, in building systems hardware and software, we inThe Aggregateoften have found it necessary to do relatively obscure l 阅读全文
posted @ 2013-05-27 00:36 IAmAProgrammer 编辑
摘要:http://www.hackersdelight.org/hdcodetxt/nlz.c.txt// This has the programs for computing the number of leading zeros// in a word.// Max line length is 57, to fit in hacker.book.// Compile with g++, not gcc.#include <stdio.h>#include <stdlib.h> // To define "exit", req'd by X 阅读全文
posted @ 2013-05-27 00:30 IAmAProgrammer 编辑
摘要:http://graphics.stanford.edu/~seander/bithacks.htmlBit Twiddling HacksBy Sean Eron Andersonseander@cs.stanford.eduIndividually, thecode snippets here are in the public domain(unless otherwise noted) — feel free to use them however you please. The aggregate collection and descriptions are ©1997- 阅读全文
posted @ 2013-05-27 00:21 IAmAProgrammer 编辑
摘要:#define SVC_0 0#define SVC_1 1#define SVC_2 2void SVC_Handler( void ){ asm("TST LR, #4"); asm("ITE EQ"); asm("MRSEQ R0, MSP"); asm("MRSNE R0, PSP"); asm("B SVC_Handler_main");}void Dummy0_Handler( unsigned int * svc_args ){ svc_args[6] += 4; // skip 阅读全文
posted @ 2013-05-01 01:00 IAmAProgrammer 编辑
摘要:QuickSort AlgorithOne of the common problems in programming is to sort anarray of valuesin some order (ascending or descending).While there are many "standard" sorting algorithms, QuickSort is one of the fastest.Quicksort sorts by employing adivide and conquer strategyto divide a list into 阅读全文
posted @ 2013-04-28 23:21 IAmAProgrammer 编辑
摘要:/*The CRC calculation unit mainly consists of a single 32-bit data register, which:is used as an input register to enter new data in the CRC calculator(when writing into the register) holds the result of the previous CRC calculation(when reading the register)Each write operation into the data regist 阅读全文
posted @ 2013-04-28 18:36 IAmAProgrammer 编辑
摘要:1 uint32_t calcCrc32(uint8_t* data, uint32_t len) 2 { 3 uint32_t* pBuffer = (uint32_t*) data; 4 uint32_t BufferLength = len/4; 5 uint32_t index... 阅读全文
posted @ 2013-01-09 22:19 IAmAProgrammer 编辑
摘要:1 /*###ICF### Section handled by ICF editor, don't touch! ****/ 2 /*-Editor annotation file-*/ 3 /* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_0.xml" */ 4 /*-Memory Regions-*/ 5 define symbol __ICFEDIT_region_ROM_start__ = 0x00000000; 6 define symbol __ICFEDIT_region_ROM_en 阅读全文
posted @ 2013-01-01 14:06 IAmAProgrammer 编辑
摘要: 阅读全文
posted @ 2012-12-27 08:29 IAmAProgrammer 编辑

点击右上角即可分享
微信分享提示