📄 1044.html
字号:
int shmctl(int shmid, int cmd, struct shmid_ds *buf); <br>
<br>
struct shmid_ds { <br>
struct ipc_perm shm_perm; /* operation perms */ <br>
int shm_segsz; /* size of segment (bytes) */ <br>
time_t shm_atime; /* last attach time */ <br>
time_t shm_dtime; /* last detach time */ <br>
time_t shm_ctime; /* last change time */ <br>
unsigned short shm_cpid; /* pid of creator */ <br>
unsigned short shm_lpid; /* pid of last operator */ <br>
short shm_nattch; /* no. of current attaches */ <br>
<br>
/* the following are private */ <br>
<br>
unsigned short shm_npages; /* size of segment (pages) */ <br>
unsigned long *shm_pages; /* array of ptrs to frames -> SHMMAX */ <br>
struct vm_area_struct *attaches; /* descriptors for attaches */ <br>
}; <br>
<br>
shm_perm <br>
<br>
This is an instance of the ipc_perm structure, which is defined for us in <br>
linux/ipc.h. This holds the permission information for the segment, <br>
including the access permissions, and information about the creator of the <br>
segment (uid, etc). <br>
<br>
shm_segsz <br>
<br>
Size of the segment (measured in bytes). <br>
<br>
shm_atime <br>
<br>
Time the last process attached the segment. <br>
<br>
shm_dtime <br>
<br>
Time the last process detached the segment. <br>
<br>
shm_ctime <br>
<br>
Time of the last change to this structure (mode change, etc). <br>
<br>
shm_cpid <br>
<br>
The PID of the creating process. <br>
<br>
shm_lpid <br>
<br>
The PID of the last process to operate on the segment. <br>
<br>
shm_nattch <br>
<br>
Number of processes currently attached to the segment. <br>
(http://www.fanqiang.com/) 进入【UNIX论坛】 <br>
<br>
<br>
Linux程式设计-24.Semaphores <br>
http://www.openchess.org/noitatsko/programming/ (2001-05-27 15:00:00) <br>
<br>
semget <br>
semop <br>
semctl <br>
<br>
<br>
<br>
Linux程式设计-25.Message Queues <br>
http://www.openchess.org/noitatsko/programming/ (2001-05-27 16:10:00) <br>
msgget <br>
msgsnd <br>
msgctl (http://www.fanqiang.com/) 进入【UNIX论坛】 <br>
<br>
<br>
Linux程式设计-26.PIPE <br>
http://www.openchess.org/noitatsko/programming/ (2001-05-27 17:04:00) <br>
a pipe is a method of connecting the standard output of one process to the standard input of another. <br>
<br>
They are half-duplex. Data flows only in one direction. <br>
<br>
They can be used only between processes that have a common ancestor. Normally a pipe is created by a process, that process calls fork, and the pipe is used between the parent and child. (http://www.fanqiang.com/) 进入【UNIX论坛】 <br>
<br>
Linux程式设计-27.GNU Debugger <br>
http://www.openchess.org/noitatsko/programming/ (2001-05-27 18:08:01) <br>
gdb/xxgdb <br>
<br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
启动方式 <br>
你可以单独启动gdb,不过一般来说,启动方式都会带一两个参数。 <br>
<br>
「gdb program」:指定要除错的程式。 <br>
「gdb program core」:指定要除错的程式及其coredump档。 <br>
「gdb program pid」:指定要除错的程式及目前其正在执行的process id。 <br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
命令说明 <br>
attach pid <br>
at pid <br>
接上一个已经在执行的行程pid。这会使pid暂停,中断任何sleep及可中断的可系统呼叫。 <br>
<br>
backtrace, bt, where, w <br>
显示追踪堆叠。 <br>
<br>
break [filename:]function | line | address <br>
b [filename:]function | line | address <br>
设定中断点。您可以指定函数名称、行数、甚至记忆体位址。 <br>
<br>
c <br>
中断点後,继续执行程式。 <br>
<br>
clear [filename:]function | line | address <br>
清除中断点。 <br>
<br>
condition breakid expression <br>
根据中断点号码来设定中断状况。 <br>
<br>
delete breakid <br>
清除中断点breakid。 <br>
<br>
detach pid <br>
解除目前接上的行程。 <br>
<br>
display expression <br>
每次中断时,显示expression的值。 <br>
<br>
help [name] <br>
辅助说明 <br>
<br>
jump address <br>
跳到指定的位址,并开始执行。 <br>
<br>
list (address) <br>
l (address) <br>
列出位置附近的10行。 <br>
<br>
next, n <br>
执行到下一行。 <br>
<br>
nexti <br>
执行下一个处理器指令。 <br>
<br>
print expression <br>
p expression <br>
列出详细的expression值。 <br>
<br>
run, r <br>
从头开始执行目前程式。 <br>
<br>
set expression <br>
设定参数值。 <br>
<br>
step, s <br>
执行一个程式指令。 <br>
<br>
stepi <br>
执行一个处理器指令,遇到函数时,追踪进去。 <br>
<br>
undisplay <br>
取消display。没有参数的话,取消全部。 <br>
<br>
whatis <br>
显示expression的资料型态。 <br>
<br>
quit <br>
离开。 <br>
<br>
x <br>
与print类似,不过仅显示位址内容的简约格式。 <br>
<br>
<br>
<br>
Linux程式设计-28.GNU Make <br>
http://www.openchess.org/noitatsko/programming/ (2001-05-27 19:00:00) <br>
<br>
dependency, target, rule <br>
<br>
<br>
<br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
变数(Variable) <br>
OBJS = <br>
<br>
OBJS := <br>
OBJS += <br>
<br>
<br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
字尾法则(Suffix Rules) <br>
<br>
<br>
<br>
Linux程式设计-29.时间处理 <br>
http://www.openchess.org/noitatsko/programming/ (2001-05-27 20:10:01) <br>
UNIX及Linux的时间系统是由「新纪元时间」Epoch开始计算起,单位为秒,Epoch则是指定为1970年一月一日凌晨零点零分零秒,格林威治时间。 <br>
目前大部份的UNIX系统都是用32位元来记录时间,正值表示为1970以後,负值则表示1970年以前。我们可以很简单地计算出其时间领域: <br>
<br>
2^31/86400(s) = 24855.13481(天) ~ 68.0958(年) <br>
<br>
1970+68.0958 = 2038.0958 <br>
1970-68.0958 = 1901.9042 <br>
<br>
时间领域为[1901.9042,2038.0958]。 <br>
<br>
准确的时间为2038年一月十八日星期一晚上十点十四分七秒。那一刻,时间将会转为负数,变成1901年十二月十三日黑色星期五下午三点四十五分五十二秒,然後Jason就会跑出来用斧头砸掉您的电脑。 <br>
<br>
这就是所谓的UNIX 2038 BUG,或者您也可戏称为Jason hatchet bug。在大部份的UNIX上,并没有所谓Y2K问题,不过都有2038年问题。 <br>
<br>
在一些64位元的平台上,例如Digital Alpha、SGI、Sparc等等,则用64位元来表示时间。 <br>
<br>
2^63/86400 ~ 1E14(天) ~ 2.92E11(年) <br>
<br>
大约是292亿年。 <br>
<br>
因此,使用64位元的电脑可能会有Armageddon bug的问题。届时位於猎户座旋臂的太阳,已经是黑矮星或暗黑物质,猎户座旋臂大概也已经被重力波震断,银河系大概则已经变成小型似星体了。 <br>
<br>
虽然许多人认为UNIX的2038年问题会随着科技的进步,而将电脑逐步汰换成64位元电脑,因此无须担心。但我个人相信,在2038年,依然会有许多状况出现。因为,就事实而言,目前许多UNIX系统都有足够的能力服役到2038年而毫无问题。因此,如果有意添购电脑主机,而且有预期会使用到那个时候,最好是选购64位元电脑,确认只有世界末日问题(除非您想要把资料流传给下一个宇宙,那就要另当别论了)。 <br>
<br>
<br>
<br>
-------------------------------------------------------------------------------- <br>
<br>
取得目前时间 <br>
在所有的UNIX下,都有个time()的函数 <br>
#include <br>
time_t time(time_t *t); <br>
<br>
这个函数会传回从epoch开始计算起的秒数,如果t是non-null,它将会把时间值填入t中。 <br>
<br>
对某些需要较高精准度的需求,Linux提供了gettimeofday()。 <br>
#include <br>
#include <br>
int gettimeofday(struct timeval * tv,struct timezone *tz); <br>
int settimeofday(const struct timeval * tv,const struct timezone *tz); <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -