IPC Flashcards

1
Q

What’s MultiProcessing?

A

Using several CPU cores (= processors) for running a single job to
solve a single “problem”

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

What threads don’t share?

A

Registers and stack.

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

What is the clone syscall?

A

Creates a new “child” process, similar to fork but gives more precise control over the creation.

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

What’s a pipe?

A

A pipe is a pair of two file descriptors (fd for short)
– int pipe_fd[2]
• Such that each integer is a handle to a kernel communication object
– pipe_fd[0] = read side of the communication channel
– pipe_fd[1] = write side of the communication channel
– Everything written via pipe_fd[1] can be read via pipe_fd[0]

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

What happens when a running process attempts to read through pipe_fd[0] but
nothing has been written yet via pipe_fd[1]?

A

the process will block

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

What happens upon writing to a pipe whose read end is close()d?

A

SIGPIPE (“broken pipe”)

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

What is the macro that provides safe system calling?

A
#define DO_SYS( syscall ) do { \
/* safely invoke a system call */ \
if( (syscall) == -1 ) { \
perror( #syscall ); \
exit(1); \
} \
} while( 0 )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why do we need a sfae syscall invocation macro (with the do-while trick)?
why not just use an If?

A
Because then, code like this won’t compile
*/
if( condition )
DO_SYS( read(fd,buf,bufsiz) );
else
printf(“can’t read()”)

Where DO_SYS is used as a statement

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

Why should read/write often be wrapped in a loop?

A

both syscalls return the

number of bytes they read/written

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

How communication is done in threads and how in processes?

A
Threads = communication is done via shared memory (more efficient and complicated)
Processes = communication is done via explicit message passing (less efficient and complicated).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What’s Multitasking?

A

– Having multiple processes time slice on the same core

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

What’s Multiprogramming?

A

– Having multiple jobs in the system (either on the same core or on
different cores)

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