- 博客(59)
- 资源 (2)
- 收藏
- 关注
原创 后端设计中特殊单元
特殊的物理单元:(1) FILLER单元 主要是把扩散层连接起来满足DRC规则和物理设计要求,并形成电源线和地线的轨道。(2)电压钳位单元 数字电路中的某些信号端口,或者闲置信号的端口需要钳位在固定的逻辑电平上。而且还可以起到隔离普通信号和特殊信号的作用。(3)二极管单元 为了避免芯片在加工过程中的天线效应导致器件栅氧击穿,通常布线完成后需要在违反天线规则的栅输入端加入反偏二极管,这
2015-06-07 16:41:44
1486
原创 Makefile模版
src = $(wildcard $(srcpath)*.c)obj = $(patsubst $(srcpath)%.c,$(objpath)%.o, $(src))target = appsrcpath = ../src/objpath = ../obj/incpath = ../inc/CC = gccCPPFLAGS = -ICFLAGS =
2014-04-02 15:01:08
482
原创 Linux驱动笔记
一、描述内存分配方式及他们的区别(1)从静态存储区分配。内存在程序编译时就已经分配好,这块内存在整个程序运行时期都在。例如全局变量,static变量。(2)在栈上创建。在执行函数时,函数内部局部变量的存储单元都能在栈上创建。函数执行结束时这些存储单元自动被释放。栈内存分配运算内置于处理器的指令集。(3)从堆上分配,称为动态内存分配。程序在运行的时候用malloc或者new申请任意多少的
2013-12-30 14:08:09
529
原创 Linux驱动笔记(1)
模块退出前的__exit宏表示,这个函数会被链接到.exit.text段,这个段的代码只会在模块被移除的时候执行module_init宏把akae_init函数别名为init_module的模块入口函数。module_exit宏表示把akae_exit函数别名为cleanup_module的模块退出函数。模块中都可以指定这两个宏,也可以都不使用这两个宏,但是如果仅仅调用module_i
2013-12-30 14:06:53
495
原创 sqlite3的一些常用语句
sqlite3官网地址:www.sqlite.org源上安装:sudo apt-get install libsqlite3-dev sqlite3SQL:1、创建表:create table student(id integer primary key, name text, age integer, score integer);2、查询表的内容:select *
2013-12-07 15:08:13
766
原创 线程条件变量应用(消费者和生产着模型)
#include #include #include #include struct msg{ struct msg *next; int num;};struct msg *head = NULL;pthread_cond_t has_product = PTHREAD_COND_INITIALIZER;pthread_mutex_t lock = PTHRE
2013-11-05 21:16:03
569
原创 创建10个线程创建1.txt - 10.txt,然后合并到data.txt,不需要创建线程11
#include #include #include #include #include int counter = 0;int sig = 1,fdx = -1;#define MAXNUMBER 10pthread_mutex_t counter_mutex = PTHREAD_MUTEX_INITIALIZER;pthread_cond_t counter_cond
2013-11-05 20:53:56
588
原创 哲学家就餐问题
哲学家就餐问题。这是由计算机科学家Dijksta提出的经典死锁场景问题描述:有5个哲学家,这些哲学家只做两件事--思考和吃饭,他们思考的时候不需要任何共享资源,但是吃饭的时候必须使用餐具,而餐具是有限的。原版的故事里,餐具是叉子,吃饭的时候要用两把叉子把面条从碗里捞出来。很显然把叉子换成筷子更合理,所以:一个哲学家需要两根筷子才能吃饭。现在引入问题:这些哲学家很穷,只买的起5根筷子。他们做
2013-11-05 20:49:28
1037
原创 创建10个线程创建1.txt - 10.txt,然后创建线程11 合并到data.txt
#include #include #include #include #include #include int counter = 0;#define MAXNUMBER 10pthread_mutex_t counter_mutex = PTHREAD_MUTEX_INITIALIZER;void *creat_file(void *arg){ char buf[
2013-11-04 19:21:53
538
原创 CP命令的较完整的实现
#include #include #include #include #include #include #include #include #include void cp_file(const char *src,const char *dest,mode_t mode){ char buf[1024] = {0}; int n; int fd1 = open
2013-11-02 20:29:28
613
原创 信号实现文件创建(1.txt - 10.txt),然后合并到data.txt
#include #include #include #include #include #include #include #include pid_t pid;void sig_child(int signo){ static int number = 1; int i = 0,j = 0,n; char buf[10] = {0}; //printf("chi
2013-11-02 20:25:04
581
原创 连续拷贝文件,输入$exit退出(管道实现)
#include #include #include #include #include #include #include #define MAXLINE 1024int main(int argc,char *argv[]){ int i = 0,n,fd1,fd2; int fd[2] = {0}; char buf[MAXLINE] = {0}; char s
2013-10-29 16:56:13
524
原创 详细解析sizeof和结构体对齐
sizeof 是C语言的一种单目运算符,sizeof操作符以字节数形式给出了其操作数的存储大小。操作数可以是一个表达式或者类型名。sizeof的使用方法1.用于数据类型sizeof使用形式:sizeof(type)数据类型必须用括号括住。如:sizeof(int)2.用于变量sizeof(var_name)或者sizeof var_name变量名可以不用括号括住。s
2013-10-25 19:37:49
707
原创 strtok函数和strtok_r函数的简单实现
#include #include char *mystrtok(char *str, const char *delim){ char *s_begin, *s_end; static char *savep = ""; //"root:0::/root/bash:/usr/bin"; s_begin = (str != NULL) ? str : sav
2013-10-23 20:35:26
962
原创 位运算小结(2)
12.乘法运算转换成位运算:a * (2 ^ n) a 13.除法运算转换成位运算:a / (2 ^ n) a >> n;14. a % 2 a & 1;15.if (x == a)x = b;else x = a;等价于:x = a ^ b ^ n;16. x的相反数 (~x +1)17.两个数相乘int mul(int a,int b
2013-10-23 20:17:29
617
原创 位运算总结(1)
1.判断int型变量a是奇数还是偶数a & 1= 0 是偶数a & 1 = 1 是奇数2.取int型变量a的第k位(k = 0,1,2,....,sizeof(int))a >> k & 1;3.将int型的变量a的第k位清0a = a & ~(1 4.将int型的变量a的第k位置1a = a | (1 5.将int类型的变量循环左移k位a = a
2013-10-23 19:34:25
592
原创 三大排序算法实现(冒泡,选择,快排)
#include void bubble_sort(int *array,int len){ int i,j,tmp; for(i = 0; i < len; i++) { for(j = 0; j < len - i - 1; j++) { if(array[j] > array[j + 1]) { tmp = array[j]; array[j]
2013-10-23 18:39:27
588
原创 cp命令的简单实现(可拷贝目录)
#include #include #include #include #include #include #include #define MAX_PATH 1024void dirwalk(char *srcdir,char *destdir,void (*fcn)(char *,char *));void fsize(char *srcname,char *destna
2013-10-23 17:06:58
729
原创 atoi函数的简单实现
#include #include #include #define N 100int my_atoi(char *src){ int flag = 0; int num = 0; if(src[0] == '-') { flag = 1; src++; } while(*src) { if(isdigit(*src)) { num *= 10;
2013-10-22 21:36:50
469
原创 memmove的简单实现
void *memmove(void *dest,const void *src,size_t n){ char temp[n]; int i; char *d = dest; const char *s = src; for(i = 0; i < n; i++) temp[i] = s[i]; for(i = 0;i < n; i++) d[i] = temp[i];
2013-10-22 21:29:07
420
原创 约瑟夫环(链表实现)
#include #include typedef struct node *link;struct node{ unsigned char item; link next;};static link head = NULL;link make_node(unsigned char item){ link p = (struct node *)malloc
2013-10-22 08:31:06
426
原创 strstr函数的简单实现
#include #include char *my_strstr(char *str,char *substr){ int len1 = strlen(str); int len2 = strlen(substr); if(!len2) return (char *)str; while(len1 >= len2) { len1--; if(!memcmp(str,
2013-10-21 20:29:17
597
原创 笔试小题
struct s1{char *ptr,ch;union{short a,b;unsigned int c;};struct s1 *next;};s1这个结构体大小为4字节 + 4字节 + 4字节 + 4字节 = 16字节(4字节对齐)struct s2{char a;struct s1 b;short c;};s2这个结构体大
2013-10-21 20:14:38
446
原创 笔试小题
输出 x = 3, y = 2#include int main(void){ int x = 1,y; y = x++ + x++; printf("x = %d, y = %d\n",x,y); return 0;}
2013-10-21 19:54:26
479
原创 链表的基本操作
#include #include typedef struct node *link;struct node{ unsigned char item; link next;};static link head = NULL;link make_node(unsigned char item){ link p = (struct node *)malloc(sizeof(*
2013-10-21 19:51:59
471
原创 strchr函数的简单实现
#include #include char *my_strchr(char *s,char c){ char *p = s; while(*p && *p != c) p++; if(*p == c) return p; return NULL;}int main(void){ char buf[20] = "Hello World"; char c = 'l
2013-10-21 17:06:56
787
原创 二维字符串数组排序
#include #include void sort(char *name[],int n){ char *tmp = NULL; int i,j,k; for(i = 0; i < n - 1; i++) { k = i; for(j = i + 1; j < n; j++) { if(strcmp(name[k],name[j]) > 0) k
2013-10-21 16:59:57
3031
原创 最长公共子序列
给出两个序列X和Y,任务为找到X和Y的最大公共子序列的长度,也就是说要找到一个最长的序列Z,使得Z即是X的子序列又是Y的子序列输入:abcfbc abfcabprogramming contestabcd map输出:420用字符串数组s1,s2存放两个字符串,用s1[i] 表示第i个字符,s2[j]表示第j个字符(编号从1开始),s1i表示s1前i个字符构成的
2013-10-21 16:44:13
455
原创 确定一个字符串在规定的字符串中的行列位置
#include #include int main(void){ char *str[] = {"Hello world","Hello hell","hello aka","hello hello hoho"}; char src[32] = {0}; char *tmp = NULL; int i; int len = sizeof(str)/sizeof(str[
2013-10-21 16:17:55
662
原创 利用lseek制作任意大小的文件
#include #include #include #include int main(int argc,char *argv[]){ int fd = open(argv[1],O_RDWR | O_TRUNC | O_CREAT,0644); char buf[100] = {0}; int n; //printf("Please input the s
2013-10-21 15:49:15
474
原创 strcasecmp函数简单实现
#include #include #define N 1024int my_strcasecmp(char *s1,char *s2){ int i,j; char m[N],n[N]; for(i = 0; s1[i]; i++) { m[i] = s1[i]; if(isupper(m[i])) m[i] ^= 32; m[i] = '\0'; }
2013-10-21 15:37:36
1927
原创 泛型算法的简单应用
#include typedef struct{ const char *name; int score;}student_t;typedef int (*cmp_t)(void *,void *);void *max(void *data[], int num,cmp_t cmp){ int i; void *temp = data[0]; for(i = 1; i
2013-10-21 15:09:06
514
原创 简单cp命令的实现
#include #include #include #include int main(int argc,char *argv[]){ char buf[100] = {0}; int n = 0; int fd = open(argv[1],O_RDONLY); int fp = open(argv[2],O_RDWR |O_TRUNC | O_CREAT,06
2013-10-21 14:49:07
595
原创 (Linux高级编程)读写文件
#include #include #include #include int main(int argc,char *argv[]){ char buf[100] = {0}; int i,n; int fd = open(argv[1],O_RDONLY); while(n = read(fd,buf,sizeof(buf)))//读取完成后的结束标志为n等于0 {
2013-10-21 14:16:14
484
原创 约瑟夫环(数组模拟实现)
#include #include const int MAX_NUM = 300;int aLoop[MAX_NUM + 10];int main(void){ int i,n,m; while(1) { scanf("%d%d",&n,&m);//n总人数,m要出圈的猴子数 if(n == 0) break; for(i = 0; i < n; i++)
2013-10-21 11:43:25
544
原创 strlen实现
int my_strlen(const char *str){ int i = 0; while(str[++i]); return i; }
2013-10-21 11:32:58
368
原创 strcpy简单实现
char *my_strcpy(char *dest,char *src){ int i; for(i = 0; src[i]; i++) dest[i] = src[i]; dest[i] = '\0'; return dest;}
2013-10-21 11:31:40
459
原创 strcat实现
char *my_strcat(char *dest,char *src){ char *tmp = dest; while(*tmp) tmp++; while(*src) *tmp++ = *src++; *tmp = '\0'; return dest;}
2013-10-21 10:08:48
428
原创 memset简单实现
void *my_memset(void *s,int c,int n){ int i; for(i = 0; i < n; i++) *((char *)(s + i)) = c; return s;}
2013-10-21 10:06:51
415
原创 strncat函数实现
#include #define N 50char *my_strncat(char *dest,char *src,int count){ char *tmp = dest; while(*tmp) tmp++; for(;count;count--) *tmp ++ = *src++; *tmp = '\0'; return dest;}int main(vo
2013-10-21 10:04:23
866
1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人