代码改变世界

4个月

2012-07-12 13:54 by Jeff, 657 阅读, 0 推荐, 收藏, 编辑
摘要:4个月没写任何东西 阅读全文

C++ 有限状态机

2012-03-08 22:10 by Jeff, 3667 阅读, 0 推荐, 收藏, 编辑
摘要:用一个类定义事件和状态文件:GlobalAutoDcl.hConst int NbMaxAction =10;Const int NbMaxState =5;Const int NbMaxEvent =6;Class GlobalAutoDcl{public:typedef enum {event0 = 0;event1 =1;.......}typedef enum {state0 = 0;s... 阅读全文

POJ1019

2012-01-17 16:41 by Jeff, 696 阅读, 0 推荐, 收藏, 编辑
摘要:#include "stdio.h"#include #define SUM_MAX1 45#define SUM_MAX2 9045#define SUM_MAX3 1395495#define SUM_MAX4 189414495char pre45bits [46]={"112123123412345123456123456712345678123456789"};unsigned int ... 阅读全文

POJ1035

2012-01-16 10:29 by Jeff, 539 阅读, 0 推荐, 收藏, 编辑
摘要:#include "stdio.h"struct thedic{ char wordname[17]; int thelen; }thedic_p[10010];int i =0;int p =0;int x=0;int correct =0;int j,count,len,mywordlen,totalnumber;char myword[17];char * tempwo... 阅读全文

POJ1007

2012-01-05 15:03 by Jeff, 514 阅读, 0 推荐, 收藏, 编辑
摘要:#include "stdio.h"int main(void) { int num; int length; char str_out[100][51]; int index; int index1; int result[100]; int a=0; int b=0; int min=0; int num2=0; int tem... 阅读全文

POJ1005

2012-01-05 10:01 by Jeff, 560 阅读, 0 推荐, 收藏, 编辑
摘要:#include "stdio.h"#include "math.h"int main(void) { int num; float x_value=0.0; float y_value=0.0; int a =1; int result; float length; #ifndef ONLINE_JUDGE freopen("in.txt","r... 阅读全文

ONLINE_JUDGE

2012-01-04 17:07 by Jeff, 1223 阅读, 0 推荐, 收藏, 编辑
摘要:POJ上已经定义了ONLINE_JUDGE.所以要用"ifndef", 本地IDE中的宏定义删了.scanf:%f小数点后6位%G和%g 小数点后2位,但是自动会去除末尾的0 #include "stdio.h"int main(void) { float c; float result=0.0; #ifndef ONLINE_JUDGE freopen("in.txt",... 阅读全文

Linux shell定时器

2011-12-26 16:02 by Jeff, 11679 阅读, 0 推荐, 收藏, 编辑
摘要:网上找了个例子,简单实用如下.可以有一个后台进程,在timer超时采取一些操作. #!/bin/ksh#Delaytime=0AlarmHandler(){echo "Get SIGALAM"KillSubProcsexit 14}KillSubProcs(){#kill cbmecho "it's time out,kill cbm here"if [ $? -eq 0 ];thenecho "... 阅读全文

怪异的grep结果

2011-12-20 16:00 by Jeff, 768 阅读, 0 推荐, 收藏, 编辑
摘要:原意是发现文件中IP地址为1.1.1.1的行(不需显示1.1.1.191这样的).但是写错了,忘记"."是用于匹配任意字符的.但却发现有几条grep结果很奇怪.根据GNU Grep的manual "" Match the empty string at the end of word所以当时我就写成了grep "" 结果如下:ksim@MxGms3:~> echo "1.1.1.1 games1... 阅读全文

URL2FILE

2011-12-08 16:59 by Jeff, 997 阅读, 0 推荐, 收藏, 编辑
摘要:URL2File is a free Java application able to retrieve and save the content of a given URL to a local file.URL2File Java console-mode application can be used by itself or within a shell script to retrie... 阅读全文

C primer笔记

2011-12-07 19:44 by Jeff, 545 阅读, 0 推荐, 收藏, 编辑
摘要:1. 对指针加1,等于对指针的值加上它指向的对象的字节的大小2. date+2 =&date[2]*(date+2) = date[2]3. 函数原型或者函数定义头,可以用int * ar 代替int ar[ ] int sum(int ar[],int n) int sum(int * ar,int n)4. 原型是允许省略名词的: int sum(int * ,int ); int sum(i... 阅读全文

Vxworks增加system call

2011-12-07 19:41 by Jeff, 1033 阅读, 0 推荐, 收藏, 编辑
摘要:Vxworks中增加system call的伪代码.比如用户层可以获取kernel中的time tick.#include #include unsigned short gettimdsp(void);SYSCALL_RTN_TBL_ENTRY msGetTbl[] ={ {(FUNCPTR) gettimdsp, 1, "gettimdsp", 0}};unsigned short getti... 阅读全文

C语言常用宏定义技巧

2011-11-28 14:13 by Jeff, 620 阅读, 0 推荐, 收藏, 编辑
摘要:1. 防止一个头文件被重复包含#ifndef COMDEF_H#define COMDEF_H2. 重新定义一些类型,防止由于各种平台和编译器的不同,而产生的类型字节数差异,方便移植typedef unsigned long int uint32; /* Unsigned 32 bit value */typedef unsigned short uint16; ... 阅读全文

分苹果

2011-11-03 16:31 by Jeff, 395 阅读, 0 推荐, 收藏, 编辑
摘要:Description把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。Input第一行是测试数据的数目t(0 #include #include int f(int, int); int main(){ int t, m, n, sum; scanf("%d", &t); while (t-... 阅读全文

Socket

2011-11-03 14:22 by Jeff, 740 阅读, 0 推荐, 收藏, 编辑
摘要:创建一个socket.int socket ( int domain, /* address family (AF_xxx) */ int type, /* socket type (SOCK_xxx) */ /*UDP: SOCK_DGRAM; TCP:SOCK_STREAM */ int protocol /* socket ... 阅读全文

为什么选择SMP而不是AMP

2011-09-27 16:37 by Jeff, 3662 阅读, 0 推荐, 收藏, 编辑
摘要:论坛上有问我们当时为何选择SMP而不是AMP. 不知道该如何回答,SMP和AMP的不同,从文档上有了解,但是项目为何选择SMP而不是AMP,却并不知道.自从我进入这个项目,似乎已经确定了SMP mode. 今天特地去查看了一下以前system文档,文档中原因归结为以下几点: 1. 因为AMP的核与核之间是完全独立的, 但是外部的resource并不太好分割,这样的话,不能简单的换板子就... 阅读全文

RTP memory in Vxworks

2011-08-31 10:24 by Jeff, 1158 阅读, 0 推荐, 收藏, 编辑
摘要:cmd进入Command interpreterc进入C interpreter以下是用cmd命令,打印出rtp memory的情况:有一点关于shared data比较奇怪,我open的时候大小明明设置的是0x9900300,这里显示的是0x9901000.原因应该是和WindRiver的库函数有关.[vxWorks *]# rtp meminfo -l -m 0x5a02010Memory I... 阅读全文

Windriver的项目类型

2011-08-25 14:04 by Jeff, 1000 阅读, 0 推荐, 收藏, 编辑
摘要:1. DKMUse Downloadable Kernel Module projects to manage and build modules that willexist in the kernel space.Kernel-mode development is the traditional VxWorks method of development; allthe tasks you... 阅读全文

RTP affinity

2011-08-24 12:59 by Jeff, 628 阅读, 0 推荐, 收藏, 编辑
摘要:以下代码证明: RTP affinity inherits from the task that created it.创建一个RTP,代码: #include "taskLib.h"int main(){ while(1){ taskDelay(1); } taskSuspend(taskIdSelf());}创建一个VIP,在usrAppInit.c中调用myroot().myr... 阅读全文

Symmetric multiprocessing (SMP)

2011-08-23 14:21 by Jeff, 1176 阅读, 0 推荐, 收藏, 编辑
摘要:Symmetric multiprocessing (SMP) is a variant of multiprocessing technology inwhich one instance of an operating system controls all processors, and in whichmemory is shared.===========================... 阅读全文

Shared-memory object ---VxMP

2011-08-22 13:20 by Jeff, 8865 阅读, 0 推荐, 收藏, 编辑
摘要:VxMP is a VxWorks component that provides shared-memory objects dedicatedto high-speed synchronization and communication between tasks running inseparate instances of VxWorks.=========================... 阅读全文

socket丢数据的一个原因

2011-08-09 15:59 by Jeff, 1951 阅读, 0 推荐, 收藏, 编辑
摘要:多任务环境中,某任务从socket接收数据,并传给底层处理. 程序结构如下:while(1){ socket receive; Invoke other module handle the received data;}次任务每收一条数据都发给底层去处理.处理完再收下一条数据.测试结果丢数据,ethereal上看到客户端已经发送数据,但是这个任务只收到部分数据.后来查证,每次收数据,处... 阅读全文

学习AWk,Sed

2011-07-25 17:38 by Jeff, 518 阅读, 0 推荐, 收藏, 编辑
摘要:学习AWK,SED的例子:#!/bin/kshswdirectory=”/home/jeff”################################### Function : FTP to the Server##################################function ftp2deca {ftp -n $DSPNAME$TEMPFILE”;sleep 4)|t... 阅读全文

c语言----memcpy

2011-06-01 16:43 by Jeff, 660 阅读, 0 推荐, 收藏, 编辑
摘要:搜索了网上关于,memcpy的使用方法,很多都提到,目标地址和源地址不能有重复.一般目标地址和源地址有重复时使用memmov.但是我们的环境中即使目标地址和源地址重复依然可以用memcpy.网上说VC也是不支持地址重复,但是我用codeblock可以使用,用的是mingw32.copy不能有重复的内存实现: void * __cdecl memcpy (void * dst,const void ... 阅读全文

C语言学习

2011-05-31 13:45 by Jeff, 466 阅读, 0 推荐, 收藏, 编辑
摘要:int main(){int i;char * msg= (char *)malloc(6);char buff[] ="2mxbcd";char thechar[20];char otherchar[] ="123456";msg =buff;printf("array -1 %d",otherchar[-1]);//printf("size of unsigned short is %d, ... 阅读全文

删除字符串第一个byte

2011-05-26 16:29 by Jeff, 944 阅读, 0 推荐, 收藏, 编辑
摘要:一种方式: char * mag;char buff[1000];char number;memcpy((char *)msg,buff,len);strncpy(&number,&msg[0],1);for(int i=0;i 另一种: char * mag;char buff[1000];char number;number = buff[0];memcpy((char *)msg,buff+... 阅读全文

学习language C

2011-05-26 15:29 by Jeff, 415 阅读, 0 推荐, 收藏, 编辑
摘要:不解释.int main(){int i;char * msg = (char *)malloc(6);char buff[] = "2mxbc";char onechar;for(i=0;i 阅读全文

Debugging in real-time embedded system(1)

2011-05-16 15:36 by Jeff, 624 阅读, 0 推荐, 收藏, 编辑
摘要:For the recent months, I was always focus on debugging in the real-time system Vxworks, and off course wasted too much time on some bugs. These bugs were tricky but all turned out to be simple after f... 阅读全文

走神

2011-04-08 12:15 by Jeff, 439 阅读, 0 推荐, 收藏, 编辑
摘要:又回到一年前的状态. 一种不知道自己为何每天上班的状态,一种找不到目标的状态. 比以前更糟的是,因为以前总有想做的,现在度日如年. 不想打球,不想打游戏,不想看书,不想看电视. 以为坐在电脑前总有些事情可干的,可是真的没有什么可干. 游戏都已经荒废了,被别人找乐子 篮球的论坛里都是谩骂声,NBA也是黑哨的天下 ... 阅读全文

眼不见心不烦

2011-04-06 10:20 by Jeff, 309 阅读, 0 推荐, 收藏, 编辑
摘要:Professional competition是令人感触颇深的培训,比以往参加的培训实用一些,和自己利益切身相关.害怕自己成为“职场的植物人”,所以从一个公司跳到另一个公司,这样也不能避免在新的公司成为“植物人”。我们需要不断地增加自己的实力,day by day,往自己的“品牌”里加分. 我实在烦透了这样的气氛:在上海这么偏的地方买了这么小的房子,买了车子,便觉得我们可以... 阅读全文