שיתוף PDT בין חוטים PDT Thread A Process Descriptor File Object 1 File Object 2 File 1 File 2 pthread_create Thread B Process Descriptor ה PDT משותף לכל.

Slides:



Advertisements
Similar presentations
Processes and threads. תהליכים ותתי תהליכים תהליכים –כל תוכנית שרצה היא תהליך (process) –ניתן להתפצל מתהליך אחד למספר תהליכים, בעזרת הפקודה fork(). הרבה.
Advertisements

שיטות ניתוח - דוגמא משווה
מבוא למדעי המחשב לתעשייה וניהול
4.1 Operating Systems Lecture 11 UNIX Pipes Read Handout "An Introduction to Concurrency..."
1 Processes Professor Jennifer Rexford
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
חורף - תשס " ג DBMS, צורות נורמליות 1 צורה נורמלית שלישית - 3NF הגדרה : תהי R סכמה רלציונית ותהי F קבוצת תלויות פונקציונליות מעל R. R היא ב -3NF.
Rings This chapter demonstrates how processes can be formed into a ring using pipes for communication purposes.
Exec function Exec function: - replaces the current process (its code, data, stack & heap segments) with a new program - the new program starts executing.
CS Lecture 15 Outline Process Management System calls – exec() – chdir() – system() – nice() – Accessing User and Group IDs – Redirection Lecture.
תזכורת: גרפים גרף (G=(V,E V|=n, |E|=m| מכוון \ לא מכוון דרגה של קדקד
Teaching Operating Systems With Programming and Freeware Lecture 1: Introduction, IPC and Lab1 A workshop by Dr. Junaid Ahmed Zubairi Visiting Associate.
Introduction to Linux (II) Prof. Chung-Ta King Department of Computer Science National Tsing Hua University CS1103 電機資訊工程實習.
Points on a perimeter (Convex Hull) קורס – מבוא לעבוד מקבילי מבצעים – אריאל פנדלר יאיר ברעם.
Today’s topic Inter-process communication with pipes.
Operating systems Lab 04 System Call, Nested Fork(),Exec(),Pipe()
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
Unix Processes Slides are based upon IBM technical library, Speaking Unix, Part 8: Unix processes Extended System Programming Laboratory (ESPL) CS Department.
Unix Pipes Pipe sets up communication channel between two (related) processes. 37 Two processes connected by a pipe.
Simple Shell Part 1 Due date (75%): April, 2002 Part 2 Due date (25%): Apr 5, 2002.
Slide 1 Interprocess communication. Slide 2 1. Pipes  A form of interprocess communication Between processes that have a common ancestor  Typical use:
Solutions to the first midterm COSC 4330/6310 Summer 2012.
Cli/Serv.: procs/51 Client/Server Distributed Systems v Objectives –look at how to program UNIX processes , Semester 1, Processes.
1 Week 2 The Crunchy Shell to the Soft and Chewy Kernel… Sarah Diesburg 8/3/2010 COP4610 / CGS5765.
Shell (Part 2). Example r What if we want to support something like this: m ps –le | sort r One process should execute ps –le and another should execute.
Creating and Executing Processes
System Commands and Interprocess Communication. chroot int chroot(const char *path); chroot changes the root directory to that specified in path. This.
Pipes A pipe is a simple, synchronized way of passing information between processes A pipe is a special file/buffer that stores a limited amount of data.
CS252: Systems Programming Ninghui Li Based on Slides by Prof. Gustavo Rodriguez-Rivera Topic 8: Opening Files and Starting Processes.
Chapter 71 Deadlock Detection revisited. Chapter 72 Message Passing (see Section 4.5 in Processes Chapter)  A general method used for interprocess communication.
Shell (Addendum). Example r What if we want to support something like this: m ps –le | sort r One process should execute ps –le and another should execute.
Chapter 11 Process Management
Pipe-Related System Calls COS 431 University of Maine.
Concurrent Processes Processes can concurrently run same program. Processes can concurrently run same program. Processes can start other processes. Processes.
Operating Systems Process Creation
1 Tutorial: CSI 3310 Dewan Tanvir Ahmed SITE, UofO.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Unix System Calls and Posix Threads.
CSCI 330 UNIX and Network Programming Unit XII: Process & Pipe Part 1.
Recitation 11 (Nov. 22) Outline Lab 6: interposition test Error handling I/O practice problem Reminders Lab 6: Due Tuesday Minglong Shao
Pipes Pipes are an inter-process communication mechanism that allow two or more processes to send information to each other.
Interprocess Communication
Process Management Azzam Mourad COEN 346.
Chapter 1 Introduction  What is an operating system  History of operating systems  The operating system zoo  Computer hardware review  Operating system.
CSCI 330 UNIX and Network Programming
Dsh: A Devil Shell COMPSCI210 Recitation 14 Sep 2012 Vamsi Thummala.
Dup, dup2 An existing file descriptor ( filedes ) is duplicated The new file descriptor returned by dup is guaranteed to be the lowest numered available.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
1 Unix system calls fork( ) wait( ) exit( ). 2 How To Create New Processes? n Underlying mechanism -A process runs fork to create a child process -Parent.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
4.1 Operating Systems Lecture 9 Fork and Exec Read Ch
Process Related System Calls By Neha Hulkoti & Kavya Bhat.
Using System Calls (Unix) Have to tell compiler (if C/C++) where to find the headers, etc. – i.e., the “include” files May have to tell compiler where.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Pipes and Fifos.
מספרים אקראיים ניתן לייצר מספרים אקראיים ע"י הפונקציה int rand(void);
Week 3 Redirection, Pipes, and Background
CS 3305A Process – Part II Lecture 4 Sept 20, 2017.
CS 3733 Operating Systems Topics: IPC and Unix Special Files
Pipe.
File redirection ls > out
Pipes A pipe provides a one-way flow of data example: who | sort| lpr
תרגול 8 – ק/פ ותקשורת תהליכים ב-Linux
מבוא לתכנות בWINDOWS ב#C
2/25/08 Frans Kaashoek MIT OS abstractions 2/25/08 Frans Kaashoek MIT
Unix System Calls and Posix Threads
Programming Assignment # 2 – Supplementary Discussion
Simple Shell Due date: March 27, 2002.
IPC Prof. Ikjun Yeom TA – Hoyoun
dup, dup2 An existing file descriptor (filedes) is duplicated
Pipes One-way channel joining two processes
System Programming: Process Management
Presentation transcript:

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

שיתוף PDT בין תהליך אבא לתהליך בן 46 PDT Parent Process Descriptor File Object 1 File Object 2 File 1 File 2 fork() 45 Child Process Descriptor 46 PDT 45 ה PDT מועתק מהאב לבן, אבל ה file objects לא מועתקים – הם משותפים. כמובן שאם Child פותח קובץ חדש – זה לא משפיע על Parent.

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

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

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

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

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

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

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

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

pipe- תוכנית דוגמא PDT Parent Process Descriptor … File Object 0 File Object 1 File Object pipe in File Object pipe out 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 %s\n", father_buff); exit(0); }

pipe- תוכנית דוגמא PDT Parent Process Descriptor … File Object 0 File Object 1 File Object pipe in מוחקים את ה file object כי אין יותר מצביעים אליו 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 %s\n", father_buff); exit(0); }

pipe- תוכנית דוגמא PDT Parent Process Descriptor … File Object 0 File Object 1 File Object pipe in לא מובטח שהבן רץ קודם ולכן מחכים שהבן יסיים לכתוב ל pipe. 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 %s\n", father_buff); exit(0); }

pipe- תוכנית דוגמא PDT Parent Process Descriptor … 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 %s\n", father_buff); exit(0); }

pipe- תוכנית דוגמא PDT Parent Process Descriptor … 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 %s\n", father_buff); exit(0); }

pipe- תוכנית דוגמא PDT Parent Process Descriptor … 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 %s\n", father_buff); exit(0); } מה מודפס על המסך ?

pipe- תוכנית דוגמא PDT Parent Process Descriptor … 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 %s\n", father_buff); exit(0); } לאו דווקא Who’s BAD. כי לא מובטח ש write כתבה את כל התווים או ש read קראה את כולם...

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

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

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

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

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

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

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

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

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

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

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

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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 Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT Shell SON Process Descriptor …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT Shell SON Process Descriptor PDT …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT …

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT … /bin/ls Process Descriptor

הכוונת קלט פלט PDT Shell Process Descriptor … File Object 0 File Object 1 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”,…); } Pipe File Object IN Pipe File Object OUT PDT … /bin/ls Process Descriptor /bin/ls OUTPUT

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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