OPERATING SYSTEMS 1 龚玲 lgong@sjtu.edu.cn
OPERATING SYSTEMS 龚玲 lgong@sjtu.edu.cn 1
CHAPTER 3:PROCESSES Operating System Concepts with Java-7th Edition,Nov 15,2006 Silberschatz,Galvin and Gagne 2007
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 CHAPTER 3: PROCESSES
CHAPTER 3:PROCESSES o Process Concept o Process Scheduling o Operations on Processes o Cooperating Processes o Inter process Communication o Communication in Client-Server Systems
CHAPTER 3: PROCESSES Process Concept Process Scheduling Operations on Processes Cooperating Processes Inter process Communication Communication in Client-Server Systems
REVIEW o Process states o PCB o Process scheduling queues o Schedulers o Operations on processes o http://wenku.baidu.com/course/study/77f1dcccda38376ba flfae94#665ea0c7aa00b52acfc7ca94
REVIEW Process states PCB Process scheduling queues Schedulers Operations on processes http://wenku.baidu.com/course/study/77f1dcccda38376ba f1fae94#665ea0c7aa00b52acfc7ca94
GOALS FOR TODAY o Operations on processes
GOALS FOR TODAY Operations on processes
PROCESS CREATION o Parent process create children processes,which, in turn create other processes,forming a tree of processes o Resource sharing Parent and children share all resources Children share subset of parent's resources Parent and child share no resources o Execution Parent and children execute concurrently Parent waits until children terminate
PROCESS CREATION Parent process create children processes, which, in turn create other processes, forming a tree of processes Resource sharing Parent and children share all resources Children share subset of parent’s resources Parent and child share no resources Execution Parent and children execute concurrently Parent waits until children terminate
A TREE OF PROCESSES ON A TYPICAL SOLARIS Sched pid 0 init pageout fsflush pid =1 pid =2 pid =3 inetd dtlogin pid =140 pid 251 telnetdaemon Xsession pid=7776 pid 294 Csh sdt shel pid=7778 pid =340 Csh pid=1400 Netscape emacs pid=7785 pid=8105 Is cat pid=2123 pid=2536
A TREE OF PROCESSES ON A TYPICAL SOLARIS
PROCESS CREATION (CONT.) o Address space Child duplicate of parent Child has a program loaded into it o UNIX examples fork system call creates new process exec system call used after a fork to replace the process'memory space with a new program
PROCESS CREATION (CONT.) Address space Child duplicate of parent Child has a program loaded into it UNIX examples fork system call creates new process exec system call used after a fork to replace the process’ memory space with a new program
PROCESS CREATION parent resumes wait fork() child exec() exit()
PROCESS CREATION
PROCESS CREATION IN POSIX #include #include #include int main() pid_t pid; /fork a child process * pid fork(); if (pid 0){/*error occurred * fprintf(stderr,"Fork Failed"); exit(-1); else if (pid ==0){/*child process * execlp("/bin/1s","1s",NULL); else{/*parent process * /parent will vait for the child to complete * wait(NULL); printf("Child Complete"); exit(0);
PROCESS CREATION IN POSIX