jiayi Rss

汇编 输出数字

| Posted in 汇编 |

9

汇编确实够傻,平时百用不爽的类似 printf("%dn",i)输出数字竟找不到现成的实现…汇编系统调用默认输出的是其ASCII码…

输出数字,在学习编程语言的时候还是经常用到的,比如比较个大小,排个序…一时间不能输出,郁闷至极,遂写个程序实现 有符号整形 的输出。因为学习汇编不久,像宏的实现,函数的调用当作练手之用都堆了上去,所以程序显得比较臃肿、业余。。。

环境:Linux NASM+ald (因为NASM 支持的intel 汇编和上课学的DOS下汇编语法差不多,为了考试,先用它。AT&T以后再说……),NASM 的具体应用请看其手册:http://www.nasm.us/doc/nasmdoc0.htmlald 看其帮助即可

下面的程序将 val 中的数值输出

CODE

;print_int.asm

SECTION .DATA
        val DD -10H
        len EQU $-val
  &nbsp

………

signal sigaction

| Posted in APUE |

4

As people say, the old signal() had number of problems:1. The disposition for a signal was automatically reset to its defualt each time the signal occured. So we had to reestablish the handler on catching the signal. 2.There is, however, another subtle problem after reestablish the handler: There is a window of time –after the signal has occured,but before the call to signal in the signal handler. If the same signal occured int the window of time, it would cause the default action to occur and ………

Linux 僵死进程(zombie)

| Posted in APUE |

3

Linux 中有一种“死不瞑目”的进程,叫僵死进程(zombie)。一句话定义僵死进程:In UNIX System terminology, a process that has terminated, but whose parent has not yet waited for it, is called a zombie. 这些进程可以通过 ps 命令查看:ps -el ,带有 Z 标记的为僵死进程。也可以 ps -ef | grep defunc

一个进程exit()后,内核会将它的exit status 转换为 termination status,并由内核记录。可见这个结束的进程并没有真正的被销毁,虽然它已经不占用任何内存和cpu资源,没有任何可执行代码,也不能被调度,但却残留在进程列表里,一旦这种进程过多,系统性能肯定受其影响。这就需要它的父进程为它“收尸”,来获取已经terminate的子进程的终止状态(通常wait()waitpid() 来完成)。如果父进程在子进程之前退出,子进程会变成僵死进程了么…?不会………

SuSE 安装 永中Office

| Posted in Linux |

9

永中Office出了2009个人集成版,而且完全免费使用~最主要,它有Linux平台的版本

今天有空,在SuSE下装之。功能 字体感觉比OpenOffice要好,估计在Win下可以取代MS Office了,嘿嘿。。。

SuSE安装步骤:
1.在http://www.evermoresw.com.cn/webch/download/downEIOPersonal.jsp下载Linux版本

2,解压包

CODE

tar zxvf EIOffice_Personal_Lin.tar.gz

3.安装
这里说一下,开始直接运行setup.sh文件,弹出的安装对话框一片空白。之前安装其他版本的永中Office也是这种情况。不过SuSE用户别灰心,JAVA运行边可以搞定

CODE

java -jar dispose.jar

一路下一步,OK

4.小小的配置
jiayi的机器运行永中Office,弹出的界面依然空白……想是不是GTK库不兼容…Baidu找到症结,编辑/usr/bin/eio

CODE

vi/usr/bin/eio

看到开头几句,有点崩溃。。。

#!/bin/bash
if

………

awk + expect 一例

| Posted in shell |

3

一文件,格式如下:
192.168.1.1    command1
192.168.1.2    command2
192.168.1.3    command3
192.168.1.4    command4
……….

第一列是写主机IP列表,第二列是不同的命令
现在求的脚本要实现这样的功能:
要在一台主控机上分别登陆第一列列出的ip在该台主机上执行对应的command

这个问题不管两台主机之间有没有做过信任,expect + awk 都可以搞定

解:
假设用户root,端口22。
ssh.exp文件:

CODE

#!/usr/bin/expect
set timeout 100
set ip [lindex $argv 0]
setcommand[lindex $argv1]
spawn ssh root@$ip
expect "#"
send "$command\r"
expect "#"
send "

………

口语啊口语

| Posted in 生活八卦 |

16

最近参加活动的讲座都是英文,听起来蛮吃力…有时候别人听懂了在那笑,我却想哭。。。

听力不地,口语也受影响…和老外说英语很尴尬,有时干脆和他讲中文。。。
从今天起,开始听英语新闻,看些口语资料,有机会也和同学说两句。

1. I see. 我明白了。

2. I quit! 我不干了!

3. Let go! 放手!

4. Me too. 我也是。

5. My god! 天哪!

6. No way! 不行!

7. Come on. 来吧(赶快)

8. Hold on. 等一等。

9. I agree。 我同意。

10. Not bad. 还不错。

11. Not yet. 还没。

12. See you. 再见。

13. Shut up! 闭嘴!

14. So long. 再见。

15. Why not? 好呀! (为什么不呢?)

16. Allow me. 让我来。

17. Be quiet! 安静点!

18. Cheer up! 振作起来!

19. Good job! 做得好!

20. Have fun! 玩得开心!

21. How much? 多少钱?

22. I’m full. 我饱了。

23. I’m home. 我

………

Unix time functions

| Posted in APUE |

3



Ext3 file system

| Posted in APUE |

4

File system

Super
Block
Group
Descriptors
Block
Group 1
Block
Group 2

Block
Group N

Block
Bitmap
Inode
Bitmap
Inode
Table
Data
Blocks

From the figuires above we get:

Every block group is associated with a group descriptor. All of the group descriptors are congregated following the Super Block tightly.

In the group descriptor,there is a pointer points to the refered b………

printf 星号(*)

| Posted in C/C++ |

1

Today encountered asterisk (*) when refering the printf() function. I met with it long long ago, but what it is has gone away from my mind absolutely…What the man said about the asterisk (*) is as the follows:

The format of printf() is like this

%[flags][fldwidth][precision][lenmodifier]convtype

   Format of the format string
       The  format string is a character string, beginning and ending in its initial shift state, if any.  The format st

………

Linux VPN

| Posted in Linux |

0

系统环境:CentOS5操作系统。主机VPNSRV01是我的VPN Server。主机VPNCLNT00是我的测试VPN Client。
 
Yum 安装 OpenVPN
=========================================================
[root@VPNSRV01]# yum install openvpn*
Dependencies Resolved
=============================================================================
 Package                 Arch       Version       &nbsp………