您的位置:首页 > 其它

switch二层etherchannel的配置案例及 PAGP,LACP

2015-04-05 17:46 316 查看
<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/46860.html" frameborder="0" width="468" scrolling="no" height="60"></iframe>


9 Process Relationships

1 Process Groups

1. 每个进程属于一个Process Group,这个process Group从同样的Terminal获得Signal

2. Getpgrp可以获得process Group ID,也用pid_t结构表示:

#include <unistd.h><p></p></unistd.h>
pid_t getpgrp(void);

返回调用进程所属于的Process Group ID
3. getpgid可以获得某个进程的Process Group ID

#include <unistd.h><p></p></unistd.h>
pid_t getpgid(pid_t pid);

返回pid制定的进程所属于的Process Group ID
如果参数pid = 0,则返回调用进程所属的ProcessGroup的ID

4. 每个Group都有一个Leader,这个Leader的ProcessID = Process Group ID

5. 一个进程调用setpgid来参加或者创建一个process Group:

#include <unistd.h><p></p></unistd.h>
int setpgid(pid_t pid, pid_t pgid);

成功返回0,错误返回-1
注意如果pid=pgid,则指定进程成为Process Group Leader

如果pid=0,则指定进程为调用进程

2 Sessions

1. Session是一个或者多个Process Group

2. 调用setsid函数来创建一个新的session

#include <unistd.h><p></p></unistd.h>
int setsid(void);

成功返回0,错误返回-1
3. 调用setsid函数,如果该进程不是Process Group Leader,则函数会创建一个新的Session

a. 进程成为Session的Session Leader

b. 成为新的Process Group的Leader

c. 进程没有Controlling Terminal

4. Single UNIX Specification没有Session ID,不过我们可以认为一个Session的Session Leader的Process ID = Session ID

5. getsid可以获得Session ID:

#include <unistd.h><p></p></unistd.h>
pid_t getsid(pid_t pid);

成功返回Session Leader的Process ID,错误返回-1
同样的,pid = 0标明是调用进程

3 Controlling Terminal

Session和Process Group有下面特性:

1. Session只能有一个Controlling Terminal

2. Session Leader和Controlling Terminal建立联系,称之为Controlling Process

3. Session中的Process Group可以被分为一个Foreground process group和多个Background process group

4. 按下Interrupt Key (DELETE or CTRL+C)或者Quit Key (Ctrl+\),signal会发送给Foreground Process Group中的所有Process

5. 如果network/modem disconnect被检测到,则Controlling Process会收到一个hang-up signal

6. 大部分时候Controlling Terminal就是我们Login时候的Terminal

4 tcgetpgrp, tcsetpgrp, tcgetsid

1. 下面这些函数可以被用来告诉Kernel那些Process Group是Foreground,那些是Background:

#include <unistd.h><p></p></unistd.h>
pid_t tcgetpgrp(int filedes);

成功返回Foreground Process Group的ID,错误返回-1

int tcsetpgrp(int filedes, pid_t pgrpid);

成功返回0,错误返回-1
2. tcgetpgrp返回filedes对应的Terminal的Foreground process group ID,而tcsetpgrp可以设置foreground process group id

3. tcgetsid函数可以获得filedes所对应的Session ID,也就是Session Leader的Process Group ID

#include <termios.h><p></p></termios.h>
pid_t tcgetsid(int filedes);

成功返回Session ID,错误返回-1

Links

进程编程1 – UNIX高级环境编程7章读书笔记
进程编程2 – Unix环境高级编程8章读书笔记
进程编程3 - UNIX高级环境编程第9章读书笔记
UNIX信号(signal)编程 - UNIX高级环境编程第10章读书笔记
使用pthread库进行多线程编程1 - UNIX环境高级编程第11章读书笔记
使用pthread库进行多线程编程2 - UNIX高级环境编程第12章读书笔记

作者: ATField
E-Mail: atfield_zhang@hotmail.com
Blog: http://blog.csdn.net/atfield

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1540823
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: