2006年7月6日

http://www.csit.fsu.edu/~burkardt/data/data.html
可以从中找到大部分文件格式的相关信息。例如BMP,Obj等等。

http://www.csit.fsu.edu/~burkardt/data/obj/obj.html
介绍OBJ文件格式,关键是当中提供了读写和转换OBJ文件的工具建议。

posted @ 2006-10-31 00:11 cjren 阅读(262) | 评论 (0)编辑 收藏
 

 helloWorldEg.jpg
就一幅图,仔细看看和联想一下,也许会有点得益:-)

posted @ 2006-07-23 20:14 cjren 阅读(258) | 评论 (0)编辑 收藏
 
What do you know The Life Cycle of a Thread?
threads-states.gif
Can you say something about the life cycle of a thread, it's creating, starting, running, not runnale, and stopping? If you do want to know about more, please check it out: http://java.sun.com/docs/books/tutorial/essential/threads/lifecycle.html
posted @ 2006-07-23 20:10 cjren 阅读(313) | 评论 (0)编辑 收藏
 

(1)
The Art of Programming Language
《计算机程序设计艺术》 清华大学出版社

(2)
Introduction to Algorithms, Second Edition
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein
MIT
《算法导论,影印版》高等教育出版社

(3)
Intruduction to The Design and Analysis of Algorithms
(US)Anany Levitin
算法设计与分析基础
潘彦 译 
清华大学出版社

其实第一本我没有看过,只是提及算法方面的书籍,这一本好像都应该为人所知道似的。第二本的课程资料可以在mit的open course ware页面下载。第三本的译本很不错,感觉很有点幽默有趣,而且书的结构挺新颖,不至于让人马上对算法这东西觉得恐怖和烦闷。推荐第三本。

posted @ 2006-07-23 19:38 cjren 阅读(730) | 评论 (0)编辑 收藏
 

移动 -- 只有GSM,GPRS是GSM的升级版,134-139 手机使用移动的SIM卡       

联通 -- GSM  130,131,132       手机使用联通SIM卡
         -- CDMA 133 (联通新时空),手机使用UIM卡


GSM比较简单。所谓的GSM 900/1800/1900是指GSM手机的工作频率,分别是中国移动支持的900MHz,1900MHz和美国常用的1900MHz。在国内用支持900MHz和1800MHz的GSM 900/1800双频手机就可以了。如果要出国到美国用的,就要用支持1900MHz的三频手机了。

CDMA比GSM的通话质量、手机辐射小和保密性方面都好,但是技术!=市场。
CDMA -- CDMA800
            -- CDMA 1X 现在联通CDMA网络所采取的技术。与真正的CDMA2000相比,CDMA 1x就像我刚才说的,只能支持到153.6kbps的数据速度,因此被称为是2.5G的技术,还不是真正3G的技术。
            -- CDMA2000 一种3G的标准。


3G 有三个标准
            -- WCDMA 有利于中国移动,设备由欧洲进口,容易升级到WCDMA。这套系统能够架设在现有的GSM网络上,对于系统提供商而言可以较轻易地过渡,而GSM系统相当普及的亚洲对这套新技术的接受度预料会相当高。因此W-CDMA具有先天的市场优势。
 
             -- CDMA2000 利于联通,设备由美国进口,容易升级到CDMA2000。目前使用CDMA的地区只有日、韩和北美,所以CDMA2000的支持者不如W-CDMA多。不过CDMA2000的研发技术却是目前各标准中进度最快的,许多3G手机已经率先面世。

             -- TD-SCDMA 中国自己有独立知识产权的产品。采用这一标准,对于国防等重要领域国民经济安全有利。据说中国电信和中国网通都在申请移动运营牌照,他们倾向于TDS-CDMA。
       至于现在中国采用哪一种现在还没有定论。毕竟需要市场和企业来最终决定,记住技术优秀的并不代表最终就能胜出。

posted @ 2006-07-23 19:28 cjren 阅读(540) | 评论 (0)编辑 收藏
 

"Computer science is no more about computers than astronomy is about telescopes."

                                                  E. W. Dijkstra
计算机是一个工具,一个人造的工具,人制造工具的目的是什么?协助自己完成生产劳动,或确切地说是完成自己生存和生活的需要。由于需要完成大量的运算而产生的计算机,即使是到现在也局限于信息的处理,包括简单的运算和信息(数字)的存储。

而在学习当中,“sprint,struct”等这些名字听起来真的很大,而我常问自己“我需要学习它吗?”。是否不懂它们就不算懂java了呢?我从4月份开始觉得java离自己越来越远了,因为我上许多的关于java的论坛,看到的极大部分都是讨论框架,而我对此没有什么概念。“需求驱动学习”是我的信条,没有这个需求,你就没有学习那相应知识的必要,更没有动力。也许这是我懒的借口:-) 大概是自己尚且是学生,没有投身都企业生产当中因此对这些企业开发的知识没有概念吧。反正觉得现在没有学这个的必要,谁知道两年后是否有什么summer or XXname的框架出现呢?

这个暑假其实自己还是想把握时间看看书的,反正又没有找到实习工作。例如data structure & algorithm,算法分析这门课没有学过,真的遗憾,只能自己补补;还有那Developing Games in Java的part 3,当中讲的是3d的renderring,而不涉及opengl以及java3d或opengl binding等API,自己还是很有兴趣的。而昨天在国外的大学的网站上下载了一个OS课程的lecture notes,正好复习一下操作系统的概念。

posted @ 2006-07-08 10:25 cjren 阅读(633) | 评论 (1)编辑 收藏
 
     摘要: 2006-7-7 CP2003 -- Principles of Programming Languages 1997 This course (subject) comes frome http://www.cs.jcu.edu.au/Subjects/cp2003/1997/lecturenotes.html, and you can fin...  阅读全文
posted @ 2006-07-07 10:49 cjren 阅读(601) | 评论 (0)编辑 收藏
 

上午看某文章时候涉及缓冲区溢出的问题,谈到C的栈和堆,有所不懂于是baidu了一下发现论坛上的解释都较为凌乱,google一下后发现国外大学的Lecture Notes 中有不少的说明,下面简单的摘录三段,一是c中的,二是对于java的,三是从os角度看的。

Stack vs Heap Allocation
How the memory of the computer is organized for a running program? When a program is loaded into memory, it is organized into three areas of memory, called segments: the text segment, stack segment, and heap segment. The text segment (sometimes also called the code segment) is where the compiled code of the program itself resides. This is the machine language representation of the program steps to be carried out, including all functions making up the program, both user defined and system.

The remaining two areas of system memory is where storage may be allocated by the compiler for data storage. The stack is where memory is allocated for automatic variables within functions. A stack is a Last In First Out (LIFO) storage device where new storage is allocated and deallocated at only one ``end'', called the Top of the stack. This can be seen in Figure 14.13. 
 figure14.13.gif

When a program begins executing in the function main(), space is allocated on the stack for all variables declared within main(), as seen in Figure 14.13(a). If main() calls a function, func1(), additional storage is allocated for the variables in func1() at the top of the stack as shown in Figure 14.13(b). Notice that the parameters passed by main() to func1() are also stored on the stack. If func1() were to call any additional functions, storage would be allocated at the new Top of stack as seen in the figure. When func1() returns, storage for its local variables is deallocated, and the Top of the stack returns to to position shown in Figure 14.13(c). If main() were to call another function, storage would be allocated for that function at the Top shown in the figure. As can be seen, the memory allocated in the stack area is used and reused during program execution. It should be clear that memory allocated in this area will contain garbage values left over from previous usage.

The heap segment provides more stable storage of data for a program; memory allocated in the heap remains in existence for the duration of a program. Therefore, global variables (storage class external), and static variables are allocated on the heap. The memory allocated in the heap area, if initialized to zero at program start, remains zero until the program makes use of it. Thus, the heap area need not contain garbage.
小结:
Stack: automatic variables within functions
Heap: global variables (storage class external), and static variables
============================
In java 情况如下
(1)
 The stack is the program memory area, so all your primitive type variables and the memory adress of your objects are written on the stack. It is a fast access valuable memory area.
The heap is where the VM keeps the objects, and it is a huge amount of memory. When you create an object, the VM puts the object in the HEAP and puts the adress of the object created on the STACK.
(2)
 There are two kinds of memory used in Java. These are called stack memory and heap memory. Stack memory stores primitive types and the addresses of objects. The object values are stored in heap memory. An object reference on the stack is only an address that refers to the place in heap memory where that object is kept.
 It is useful to know that these two different kinds of memory exist in Java. Stack memory is the program's memory, and heap memory resides outside of the program.这好像有点跟C的不同(相反)。
引入一点垃圾回收机制的知识
 When you need a new object, Java allocates the required memory. When you are done with an object, the memory is reclaimed for you automatically via Java's garbage collection facility.
 Garbage collection runs as a thread in the background, looking for objects that no longer have a usable reference. When it finds them, it destroys them and reclaims the memory.
 The implementation of garbage collection varies between Java Virtual Machines. They generally follow the same process, however. First, the garbage collector gets a snapshot of all running threads and all loaded classes. Then, all objects that are referred to by this thread set are marked as current. The process stops when all objects that it is possible to reach have been marked and the rest have been discarded.
 In order to help the Virtual Machine, it is a good idea to remove your references to unneeded objects. This is often done by simply setting your reference to null:
 Test t = new Test();
 t.someAction();
 // all done
 t = null;
小结:
Stack: Primitive data types(primitive types), the addresses of objects(=references).
Heap:  objects.

===============================================
从系统的角度看 stack(栈)和heap(堆)
Dynamic Data Structures: The Heap
A typical personal computer or workstation today has somewhere between 16 and 64 megabytes of RAM installed. Using a technique called virtual memory, the system can swap pieces of memory on and off the machine's hard disk to create an illusion for the CPU that it has much more memory, for example 200 to 500 megabytes. While this illusion is complete as far as the CPU is concerned, it can sometimes slow things down tremendously from the user's perspective. Despite this drawback, virtual memory is an extremely useful technique for "increasing" the amount of RAM in a machine in an inexpensive way. Let's assume for the sake of this discussion that a typical computer has a total memory space of, for example, 50 megabytes (regardless of whether that memory is implemented in real RAM or in virtual memory).
The operating system on the machine is in charge of the 50-megabyte memory space. The operating system uses the space in several different ways, as shown here:

 c-heap.gif
The operating system and several applications, along with their global variables and stack spaces, all consume portions of memory. When a program completes execution, it releases its memory for reuse by other programs. Note that part of the memory space remains unused at any given time.

This is, of course, an idealization, but the basic principles are correct. As you can see, memory holds the executable code for the different applications currently running on the machine, along with the executable code for the operating system itself. Each application has certain global variables associated with it. These variables also consume memory. Finally, each application uses an area of memory called the stack, which holds all local variables and parameters used by any function. The stack also remembers the order in which functions are called so that function returns occur correctly. Each time a function is called, its local variables and parameters are "pushed onto" the stack. When the function returns, these locals and parameters are "popped." Because of this, the size of a program's stack fluctuates constantly as the program is running, but it has some maximum size.

As a program finishes execution, the operating system unloads it, its globals and its stack space from memory. A new program can make use of that space at a later time. In this way, the memory in a computer system is constantly "recycled" and reused by programs as they execute and complete.

In general, perhaps 50 percent of the computer's total memory space might be unused at any given moment. The operating system owns and manages the unused memory, and it is collectively known as the heap. The heap is extremely important because it is available for use by applications during execution using the C functions malloc (memory allocate) and free. The heap allows programs to allocate memory exactly when they need it during the execution of a program, rather than pre-allocating it with a specifically-sized array declaration.

posted @ 2006-07-06 17:30 cjren 阅读(4415) | 评论 (3)编辑 收藏
 


在尝试建立自己的可重用package的时候,对package和import语句做了些试验,记录结果如下。

使用说明:
(1)对于src\com\cjren\util\ClassA.java这个提供给其他类使用的class.
package com.cjren.util;
public class ClassA {
  ...
}
编译时:
javac -d . ClassA.java  // -d . 表示了以当前目录为package语句生成的相对根目录。
结果是在ClassA.java所在的目录下生成了com.cjren.util包,里面含ClassA.class,这个包可以复制剪贴到其他的地方供其他类使用。
Notes:
必须使用"-d .",否则ClassA.class并不会放在com.cjren.util包里面,而是生成在和ClassA.java相同的目录下。


(2)对于要使用ClassA的ClassB.java.
import com.cjren.util.ClassA;
public class ClassB {
  ... // use ClassA here
}

To compile: javac ClassB.java
To run:     假设com包放在和ClassB.java的当前目录
            java ClassB       
            // or java -cp . ClassB // here use the "-cp ." as the current directory to find the package com.
            假设com包放在D:\Program Files\Java\mypackages下
            java -cp D:\Program Files\Java\mypackages ClassB

Notes:
错误一:
package com.cjren.util;
public class ClassA {
  ...
}
编译后直接把com.cjren.util包里面的ClassA.class文件拷贝到和ClassB.java相同的目录下直接使用,
public class ClassB {
  ... // use ClassA here
}
To compile: javac ClassB.java
错误信息是
"ClassB.java:某一行: 无法访问 ClassA
 错误的类文件: .\ClassA.class
 类文件包含错误的类: com.cjren.util.ClassA
 请删除该文件或确保该文件位于正确的类路径子目录中。"
想一想为什么出错信息是说:“错误的类文件: .\ClassA.class, 类文件包含错误的类: com.cjren.util.ClassA”呢?因为"错误的类文件: .\ClassA.class"当中包含了"错误的类: com.cjren.util.ClassA"这个信息,而这个"com.cjren.util.ClassA"是在ClassA.java中的"package com.cjren.util;"语句所造成的。
正确的做法是把ClassA.class所在的包整个复制粘贴到ClassB.java所在的目录下,或者在ClassB.java所在的目录下人为手动的建立com\cjren\util\目录,然后直接把ClassA.class文件复制粘贴到此。这暗示了代码生成的包和手动建立的目录可能是一样。
可见,当ClassA.java的源代码中含"package com.cjren.util;"语句,则生成com.cjren.util包里面的ClassA.class文件里面应该就也包含了自己这个class文件所属的包信息,所以这个ClassA.class只能放在这个代码中已经指定的特定包的路径下使用,而不能把这个ClassA.class独立出来使用,因为这样的话将ClassA.class文件属性中的的包信息不相符。当然当这个ClassA.java没有显式地制定package语句信息时候,我怀疑(也觉得应该)是默认在ClassA.class文件当中包含了包的信息就是".",可以理解为默认的加入了"package .;"语句。

错误二:
public class ClassA {
  ...
}
编译后这个ClassA.class文件中含有的包的信息是"."当前目录就包!
把这个ClassA.class文件,移到以ClassB.java所在的目录为当前父目录的人为手动建立的com\cjren\util目录下。
import com.cjren.util.ClassA;
public class ClassB {
  ... // use ClassA here
}

To compile: javac ClassB.java
错误信息是
"ClassB.java:某一行: 无法访问 com.cjren.swing.ClassA
 错误的类文件: .\com\cjren\util\ClassA.class
 类文件包含错误的类: ClassA
 请删除该文件或确保该文件位于正确的类路径子目录中。"
想一想为什么出错信息是说:“错误的类文件: .\com\cjren\util\ClassA.class,类文件包含错误的类: ClassA”呢?因为你这个com.cjren.util包中的ClassA.class文件本来所默认的包信息是".",在ClassA.java中并没有使用"package"语句指定ClassA应该属于包com\cjren\util这个信息。

小结:
在尝试过程当中发现,
public class ClassA {
  ...
}

package com.cjren.util;
public class ClassA {
  ...
}
这两个只差了一个package语句的class文件大小有十几到几十k上的区别,这可能进一步证明了.java文件中的package语句会在.class文件中加入相应的包信息,这个包信息决定了这个class被使用时候的方式(是否需要import特定的包)。
还有一点要注意的是:
package com.cjren.util;
public class ClassA {
  ...
}
之后无论是使用 javac ClassA.java 或者 javac -d . ClassA.java编译都不会影响ClassA.class文件当中所含有的包信息,这两种编译方式所造成的区别在上面的使用说明中已经说过了。


 

posted @ 2006-07-06 09:00 cjren 阅读(809) | 评论 (3)编辑 收藏