Lecture 3-1 - More on Processes Flashcards

1
Q

What are “handles”?

A

It’s an array in the process space that allows I/O access as well as read write to files. Each index of the array corresponds to a device.

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

Where are the handles stored?

A

In the kernel memory space.

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

What are the handles 0, 1, and 2 used for by default?

Why do we separate 1 and 2?

A
  1. Stdin
  2. Stdout
  3. Stderr
    By having error separate from stdout, we can separate them out as needed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s another name for handles?

A

File Descriptors.

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

Does a parent and a child share the same file descriptor?

A

No.

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

Can we change the default file descriptors?

A

Yes.

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

When are the default file descriptors created?

A

At process creation.

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

What does the open(“filename”, …) function do?

A

It returns a file descriptor pointing to the given file. You can think that the OS did a “open” for you on stdin, stdout, stderr when it created the process

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

How can you close a file descriptor?

A

close(filedescriptor)

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

Where do user processes reside in the address space?

A

In the User Mode Space

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

Does each process have access to the full address space?

A

Yes

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

What are the three steps to command piping?

A
  1. Create a pipe() (its kind of like a mailbox, shared among all processes)
  2. Fork the process
  3. Rewire the file descriptors
    in process #0
    close(1)
    dup(f[1])
    in process #1
    close(0)
    dup(f[0])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What’s the problem with redirecting the output of a process to the input of another process?

A

Processes are independent of each other, they can’t see each other’s data. That’s why we have to use the kernel space.

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

File descriptors

A

A array structure maintained by the kernel for each process.
Held in the kernel memory and process can modify them through syscall.
Each process has its own file descriptor.

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

Write system call function

A

write(1, str, strlen(str));

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

What address space can a process use to communicate with other processes?

A

the kernel space

17
Q

Address Space Switching

A

Address space switching happens with a process switch

18
Q

What happens in the address space when you fork()?

A

the process space is duplicated, and a second kernel stack is created for the child.

19
Q

How can two processes communicate after fork()?

A

By using the kernel space

20
Q

what does dup(f[1]) do?

A

it duplicates the file descriptor f[1] into the first open file descriptor slot.