2 - Shell (Part 2) Flashcards

1
Q

How do you provide shared memory for multiple processes?

A

Use the pipe function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the restriction you must adhere to when using pipes between processes?

A

You can use pipes between processes that have a common ancestor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you create a pipe?

A
#include 
int pip(int filedes[2]);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which one do you do first: fork or pipe?

A

You pipe first, then fork. Fork will copy the parents file descriptor table to the child’s - the pipe will be connected between the two.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Once piped and forked, what should you do about the respective child’s and parent’s FD[0] and FD[1]?

A

You should close parent opposite FD[0] and FD[1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Where does FD[0] and FD[1] point to?

A

System File Table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

By default, if a writing process attempts to write to a full pipe, what happens?

A

System will automatically block the process until the pipe is able to receive the data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

If a read is attempted on an empty pipe, what happens?

A

Process will block until data is available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If a specified pipe has been opened for reading, but another process has not opened the pipe for writing, what will happen?

A

Process will block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the space called that is used by the pipe?

A

The buffer space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Is there a limit to this buffer space? What enforces it if so?

A

The OS has a limit on the buffer space used by the pipe.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the pipe return codes and what do they mean?

A
0 = ok
-1 = error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In the shared memory created by the pipe function, what does the information on the read descriptor table include? The write descriptor?

A

Info about the last location read from. Info about the last location written to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you re-route stdin and stdout?

A

Using dup() functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the library that contains the dup() functions?

A

include

How well did you know this?
1
Not at all
2
3
4
5
Perfectly