slides05 Flashcards

1
Q

three streams in a process

A
  • standard in (stream 0): default stream for input on keyboard
  • standard out (stream 1): eg. terminal screen
  • standard error (stream 2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

File Descriptor Table

A
  • each process has a unique FDT in the kernel space
  • cloned during a fork
  • index: File Descriptor
  • 0th entry: stdnin
  • 1st entry: stdout
  • 2nd entry: stderr
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

output redirection (printing to a file)

A
  • close(1) dissociates FTD[1] from the terminal
  • FDT[1] becomes available for use
  • if we run int fd = open(“abc.txt”, ), we get fd = 1 (it looks for the first available slot from the top of FTD)
  • now, whenever we call printf(), instead of displaying to the terminal, it will go into the file ‘abc.txt’
  • the redirection is only valid for the current process, you can create a child at this point and it will inherit the redirection
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

intput redirection

A
  1. close(0)
  2. open the file from which we want to receive the scanf() inputs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

command piping

A
  • one process sends its output so it becomes an input to another process
  • done using pipes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

pipe()

A
  • creates a pipe
  • two end points
  • unidirectional data flow
  • write end: pipe[1]; read end: pipe[0]
  • inside the kernel, array of two fd descriptors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

sharing information between parent and child processes using pipe

A
  • when you do a fork: FTD is copied to child process, pipe is exact same in both processes (not a copy)
  • REVIEW
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

socket

A
  • endpoint provided by OS for communication
  • pair of sockets acts as a communication link between processes
  • identified by an address:port
How well did you know this?
1
Not at all
2
3
4
5
Perfectly