[信息与通信]第四讲UNIX进程环境、进程控制和进程关系.ppt

[信息与通信]第四讲UNIX进程环境、进程控制和进程关系.ppt

  1. 1、本文档共102页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[信息与通信]第四讲UNIX进程环境、进程控制和进程关系

Lecture four: the environment of a Unix process、process control and processes relationship Ren Liyong Computer Science of UESTC Contents Process status transition diagram Process start and termination Non local jump Create and terminate process Race condition Process relationship Process status Linux的进程组织 Linux的进程结构 Linux的进程结构 Linux的进程结构 Process start A C program starts execution with a function main. When a C program is started by the kernel, a special start-up routine is called before main function is called, which obtains address of main and arguments from main. It would copy these information to u-area of process control block . int main ( int argc, char *argv[] ); Command-line arguments int main(int argc, char **argv) { int i; printf(argument number is %d\n,argc); for(i=0;iargc;i++) printf(argv[%d] : %s\n,i,argv[i]); exit(0); } Process termination There are five ways for process to terminate Normal termination Return from main; Calling exit Calling _exit Abnormal termination Calling abort; Terminated by a signal. exit and _exit Function void exit( int status ); /* stdlib.h */ void _exit (int status ); /* unistd.h */ Two functions terminate a program normally: _exit ,which returns to the kernel immediately, and exit which performs certain cleanup processing and then returns to the kernel. The exit function has always performs a clean shutdown of the standard I/O library: the fclose function is called for all open stream. This causes all buffered output data to be flushed. atexit Function #include stdlib.h int atexit ( void ( *func )(void) ); Int on_exit ( void (*func)( int, void * ), void *arg ); With ANSI C a process can register up to 32 functions that are automatically called by exit. These are registered by atexit or on_exit function The exit function calls these functions in reverse order of their registration. Example: (doatexit) static void my_exit1(void), my_exit2(void); int main(void) { if (a

文档评论(0)

qiwqpu54 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档