PDT Thread A Process Descriptor PDT File Object

בין חוטים PDT שיתוף Thread A Process Descriptor PDT File Object 1 File Object 2 Thread B Process Descriptor File 1 File 2 pthread_create . pthreads משותף לכל החוטים באותו התהליך לפי סטנדרט PDT ה

בין תהליך אבא לתהליך בן PDT שיתוף Parent Process Descriptor PDT 45 46 Child Process Descriptor File 1 File Object 2 File 2 PDT 45 46 fork() . לא מועתקים – הם משותפים file objects אבל ה , מועתק מהאב לבן PDT ה . Parent פותח קובץ חדש – זה לא משפיע על Child כמובן שאם
![תוכנית דוגמא -pipe Parent Process Descriptor int main() { int my_pipe[2]; int status; תוכנית דוגמא -pipe Parent Process Descriptor int main() { int my_pipe[2]; int status;](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-3.jpg)
תוכנית דוגמא -pipe Parent Process Descriptor int main() { int my_pipe[2]; int status; char father_buff[6]; pipe(my_pipe); status = fork(); PDT 0 1 … 45 46 File Object 0 File Object 1
![תוכנית דוגמא -pipe Parent Process Descriptor int main() { int my_pipe[2]; int status; תוכנית דוגמא -pipe Parent Process Descriptor int main() { int my_pipe[2]; int status;](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-4.jpg)
תוכנית דוגמא -pipe Parent Process Descriptor int main() { int my_pipe[2]; int status; char father_buff[6]; pipe(my_pipe); status = fork(); PDT 0 1 … 45 46 File Object 0 File Object 1 File Object pipe in File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor Child Process Descriptor int main() { int my_pipe[2]; int status; char father_buff[6]; pipe(my_pipe); status = fork(); PDT 0 1 … 45 46 File Object 0 File Object 1 File Object pipe in File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor Child Process Descriptor /* son process */ if (status == 0) { close(my_pipe[0]); PDT 0 1 … 45 46 write(my_pipe[1], “BAD", 4*sizeof(char)); exit(0); } File Object 0 File Object 1 File Object pipe in File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor Child Process Descriptor /* son process */ if (status == 0) { close(my_pipe[0]); PDT 0 1 … 45 46 write(my_pipe[1], “BAD", 4*sizeof(char)); exit(0); } File Object 0 File Object 1 File Object pipe in File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor Child Process Descriptor /* son process */ if (status == 0) { close(my_pipe[0]); PDT 0 1 … 45 46 write(my_pipe[1], “BAD", 4*sizeof(char)); exit(0); } File Object 0 File Object 1 File Object pipe in File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor Child Process Descriptor /* son process */ if (status == 0) { close(my_pipe[0]); PDT 0 1 … 45 46 write(my_pipe[1], “BAD", 4*sizeof(char)); exit(0); } File Object 0 File Object 1 File Object pipe in File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 /* son process */ if (status == 0) { close(my_pipe[0]); write(my_pipe[1], “BAD", 4*sizeof(char)); exit(0); } File Object 0 File Object 1 File Object pipe in File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 File Object pipe in else /* father process */ { close(my_pipe[1]); wait(&status); /* wait until son process finishes */ read(my_pipe[0], father_buff, 4*sizeof(char)); printf(“Who’s %sn", father_buff); exit(0); } File Object pipe out

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 File Object pipe in else /* father process */ { close(my_pipe[1]); wait(&status); /* wait until son process finishes */ read(my_pipe[0], father_buff, 4*sizeof(char)); printf(“Who’s %sn", father_buff); exit(0); } כי אין יותר מצביעים אליו file object מוחקים את ה

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 File Object pipe in else /* father process */ { close(my_pipe[1]); wait(&status); /* wait until son process finishes */ read(my_pipe[0], father_buff, 4*sizeof(char)); printf(“Who’s %sn", father_buff); exit(0); } . pipe לא מובטח שהבן רץ קודם ולכן מחכים שהבן יסיים לכתוב ל

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 else /* father process */ { close(my_pipe[1]); wait(&status); /* wait until son process finishes */ read(my_pipe[0], father_buff, 4*sizeof(char)); printf(“Who’s %sn", father_buff); exit(0); } File Object 0 File Object 1 File Object pipe in

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 else /* father process */ { close(my_pipe[1]); wait(&status); /* wait until son process finishes */ read(my_pipe[0], father_buff, 4*sizeof(char)); printf(“Who’s %sn", father_buff); exit(0); } File Object 0 File Object 1 File Object pipe in

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 File Object pipe in else /* father process */ { close(my_pipe[1]); wait(&status); /* wait until son process finishes */ read(my_pipe[0], father_buff, 4*sizeof(char)); printf(“Who’s %sn", father_buff); exit(0); } ? מה מודפס על המסך

תוכנית דוגמא -pipe Parent Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 File Object pipe in else /* father process */ { close(my_pipe[1]); wait(&status); /* wait until son process finishes */ read(my_pipe[0], father_buff, 4*sizeof(char)); printf(“Who’s %sn", father_buff); exit(0); } כתבה את כל write כי לא מובטח ש. Who’s BAD לאו דווקא . . . קראה את כולם read התווים או ש

הכוונת קלט פלט Parent Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1

הכוונת קלט פלט Parent Process Descriptor Child Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1

הכוונת קלט פלט Parent Process Descriptor Child Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1

הכוונת קלט פלט Parent Process Descriptor Child Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1

הכוונת קלט פלט Parent Process Descriptor Child Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1

הכוונת קלט פלט Parent Process Descriptor Child Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1 Myfile File Object

הכוונת קלט פלט Parent Process Descriptor Child Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1 Myfile File Object

הכוונת קלט פלט Parent Process Descriptor Child Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1 Myfile File Object

הכוונת קלט פלט Parent Process Descriptor status = fork(); if (status == 0) { PDT 0 1 … 45 46 File Object 0 File Object 1 Myfile File Object close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } ! של התהליך הקורא PDT אינה מחליפה את ה execv

הכוונת קלט פלט Parent Process Descriptor /bin/ls Process Descriptor status = fork(); if (status == 0) { close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1 Myfile File Object

הכוונת קלט פלט Parent Process Descriptor /bin/ls Process Descriptor status = fork(); if (status == 0) { PDT 0 1 … 45 46 File Object 0 File Object 1 Myfile File Object close(1); fd = open(“myfile”, O_WRONLY…); execv(“/bin/ls”, …); } ילך לקובץ ls ועכשיו כל הפלט של
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-29.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-30.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-31.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-32.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-33.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-34.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-35.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-36.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-37.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-38.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-39.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } Shell SON Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-40.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-41.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } /bin/ls Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT
![2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if 2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if](http://slidetodoc.com/presentation_image/174192cd853501964de9aed0ca76e0e7/image-42.jpg)
2 הכוונת קלט פלט Shell Process Descriptor int fd[2]; pipe(fd); status = fork(); if (status == 0) { /* first child */ close(1); dup(fd[1]); close(fd[0]); close(fd[1]); execv(“/bin/ls”, …); } /bin/ls Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); /bin/ls Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor Shell Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); /bin/ls Process Descriptor PDT 0 1 … 45 46 File Object 0 File Object 1 Pipe File Object IN Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT מהתמונה כי קשה לראות ככה משהו shell נוציא את ה

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט Shell SON 2 Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט PDT 0 1 … 45 46 status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט /bin/more Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT

2 הכוונת קלט פלט /bin/more Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT pipe כתב לו ב less יכול לקרוא את מה ש more כעת

2 הכוונת קלט פלט /bin/more Process Descriptor status = fork(); if (status == 0) { /* second child */ close(0); dup(fd[0]); close(fd[1]); execv(“/bin/more”, . . ); } close(fd[0]); close(fd[1]); PDT 0 1 … 45 46 File Object 0 File Object 1 /bin/ls Process Descriptor Pipe File Object IN PDT 0 1 … 45 46 Pipe File Object OUT /bin/ls OUTPUT כי הוא לא ישתמש בו pipe שסוגר את ה shell שתי הפקודות האחרונות המסומנות – הן של ה
- Slides: 59