Feeds:
文章
评论

Archive for the ‘Linux’ Category

#include <pthread.h> 1、创建 int pthread_create( pthread_t *tid, const pthread_attr_t *attr, void *(* func) (void *), void *arg ); attr: 线程属性包括:优先级、初始栈大小,是否应该成为一个守护线程。 缺省设置,NULL 后面是线程要执行的函数和参数 成功返回 0 2、等待一个给定线程终止 int pthread_join( pthread_t tid, void **status); statues返回等待线程的返回值 3、得到自身的pid pthread_t pthread_self(void); 4、pthread_detach函数 int pthread_detach( pthread_t pid ); 把指定的线程转变为脱离状态 一个线程或者是可汇合的(joinable,缺省值),或者是脱离的(detached)。当一个可汇合的线程终止时,它的线程ID和退出状态将留到另一个线程对它调用pthread_join。脱离线程却象守护进程:当它们终止的时,所有相关资源都被释放,我们不能等待它们终止。如果一个线程需要知道另一个线程什么时候终止,那就最好好吃第二个线程的可汇合状态。 本函数通常由想让自己脱离的线程调用,如下语句 pthread_detach( pthread_self() ); 5、终止一个线程 void pthread_exit( void *statue ); 指针sttus不能指向局部于调用对象,因为线程终止时这样的对象也消失 1.线程属性设置 [...]

Read Full Post »

1、准备好苹果丽黑字体,推荐蚂蚁修改的LiHei Pro字体,为方便,将其打包存在网盘内。 下载1:Mediafire 下载2:Fileqube 2、将字体放入字体文件夹,这里有个问题,必须要拥有系统管理权限才能在字体文件夹内进行文件复制等操作,下面进行详细说明。 (1)字体文件夹位于/usr/share/fonts 使用命令进入该文件夹:sudo gnome-open /usr/share/fonts/,建立一个新文件夹,命名为apple (2)将Apple LiHei Pro字体放入上述文件夹内。 (3)修改字体权限,确保root以外的普通用户也可以正常使用该字体 3、建立字体缓存,命令: cd /usr/share/fonts/apple/ sudo mkfontscale sudo mkfontdir sudo fc-cache -fv 4、重启电脑,设置系统字体。 系统字体设置:桌面右键“更改桌面背景”──“字体”选项,将字体都改为“LiHei Pro” Firefox字体设置:编辑──首选项──内容──字体──配置 按以上步骤设置完成即可! 5、在安装过程中,并不需要象ubuntu安装雅黑字体一样,修改字体配置文件!当然,在安装过程中可能会遇到乱码的问题,由于本人没碰到这种情况,而且水平非常有限,要是真有人不幸遇到的话,去问Google吧!

Read Full Post »

cannot restart SCIM problem

If you can not start SCIM in your ubuntu maybe you can try this method. My system works fine. add a new file called “.xsession” in the home directory paste: export XMODIFIERS=@im=scim export GTK_IM_MODULE=scim gnome-session in the file and save it Go to “System” -> “Perferences”, and select “Sessions”. In “Startup Programs”, add the command [...]

Read Full Post »

今天开始学习linux下用C开发多线程程序,Linux系统下的多线程遵循POSIX线程接口,称为pthread。 #include <pthread.h> int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*start_rtn)(void), void *restrict arg); Returns: 0 if OK, error number on failure C99 中新增加了 restrict 修饰的指针: 由 restrict 修饰的指针是最初唯一对指针所指向的对象进行存取的方法,仅当第二个指针基于第一个时,才能对对象进行存取。对对象的存取都限定于基于由 restrict 修饰的指针表达式中。 由 restrict 修饰的指针主要用于函数形参,或指向由 malloc() 分配的内存空间。restrict 数据类型不改变程序的语义。 编译器能通过作出 restrict 修饰的指针是存取对象的唯一方法的假设,更好地优化某些类型的例程。 第一个参数为指向线程标识符的指针。 第二个参数用来设置线程属性。 第三个参数是线程运行函数的起始地址。 最后一个参数是运行函数的参数。 下面这个程序中,我们的函数thr_fn不 需要参数,所以最后一个参数设为空指针。第二个参数我们也设为空指针,这样将生成默认属性的线程。当创建线程成功时,函数返回0,若不为0则说明创建线程 失败,常见的错误返回代码为EAGAIN和EINVAL。前者表示系统限制创建新的线程,例如线程数目过多了;后者表示第二个参数代表的线程属性值非法。 创建线程成功后,新创建的线程则运行参数三和参数四确定的函数,原来的线程则继续运行下一行代码。 #include<stdio.h> #include<pthread.h> #include<string.h> #include<sys/types.h> #include<unistd.h> [...]

Read Full Post »

刚才我们编译了 一个简单的hello world,在Windows下面我们习惯了多进程、多线程,但是由于uClinux只是Linux的一个子集,它没有Linux里实现多进程的fork 函数,只有vfork,但是vfork在建立子进程以后得等到子进程运行完才运行父进程,在使用的时候很不方便,不过还好,它可以实现多线程,这给我们的 编程带来了很大的方便(前面提到了,革新的光盘里uClinux是用的uC-libc的库,是不能实现多线程的,所以要使用多线程的话这里我们选用 ITSN的uClinux源码)。 编译一个简单的多线程程序 #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <pthread.h> void task(int *counter);           //声明线程1 void task2(int *counter);          //声明线程2 int gCounter = 0; int gCounter2 = 0; int main(void) { pthread_t thrd,thrd2; int result; fprintf(stderr,”hello world\n”); printf(“Thread Demo under uClinux.\n”); result = pthread_create(&thrd,NULL,(void*)task,(void*)&gCounter); if (result) { perror(“pthread [...]

Read Full Post »

http://www.ohse.de/uwe/software/lrzsz.html

Read Full Post »

1 Installing OpenOffice 3.0.0 Visit http://www.openoffice.org/ and go to the download section; select the Linux DEB download for your language… (JavaScript must be enabled in your browser to view the large image as an image overlay.) … and save it to your hard drive (e.g. on the desktop): (JavaScript must be enabled in your browser [...]

Read Full Post »

今天用code block 运行不能compile,提示是g++找不到, 就去search一下问题。在wiki ubuntu里面找到code block的有些compliler的安装方式。 This is a quick guide to get Code::Blocks up and running on your Ubuntu based Linux distribution. It is also going to make sure you can develop wxWidgets applications on your box as well. Look at the bottom of this guide for a complete command line that will install [...]

Read Full Post »

tips 1: set shared file in you linux, edit the file /etc/exports. you need add the destination folder which you want share. for example: we add one line in exports file, /home/sealedblade/ee4214 *(ro,no_root_squash,sync,subtree_check) note: * means all the client can see this shared folder, the first para. in the bracket. means read only. can be [...]

Read Full Post »

http://ubuntuforums.org/showthread.php?t=853717 i think you use this command to activate your device– Code: sudo modprobe usbserial vendor=0×6547 product=0×0232 hope it helps..

Read Full Post »

較舊的文章 »

Follow

Get every new post delivered to your Inbox.