Linux processes Flashcards

1
Q

What’s the difference between a process and a thread

A

A process is a set of resources, essentially a virtual address space.

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

What does it mean for things to run concurrently?

A

The scheduler is free to run the threads in any order / interleaving.

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

What is an important motivation for concurrency?

A

Handling I/O in separate threads to avoid blocking execution of other things

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

What are the main three statuses of a thread?

A

RUNNING (on CPU) READY (can be run but isn’t running) BLOCKED (can’t be started)

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

What is the standard OS library for threads?

A

pthreads, pthread_create, pthread_exit, pthread_join

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

How is the state of a thread stored?

A

It’s stored in a zone called TCB (Thread controll block). Each thread has its own stack.

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

What are the two basic lock operations on threads?

A

Lock.acquire() and Lock.release()

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

What happens if the scheduler runs out of processes to run?

A

The lowest priority process comes into place: the idle process. This process runs indefinitely and consumes very low power.

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

How is a process created?

A

Every process in linux is created by another process. Typically by the fork system call.

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

How does a program distinguishes whether it’s a child process or a parent process?

A

The result by the fork system call is 0 in the child and the id of the process in the parent process.

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

What happens if a thread forks off a process?

A

Only the thread that called process gets copied.

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

What is a POSIX/Unix PIPE

A

It’s a mechanism that allows two processes to send and receive data. Process A writes into a pipe, when it’s full, it blocks, then B starts rreading, when it’s empty, it blocks, and so on.

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

What’s the system call for pipes?

A

pipe.

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