Linux processes Flashcards
What’s the difference between a process and a thread
A process is a set of resources, essentially a virtual address space.
What does it mean for things to run concurrently?
The scheduler is free to run the threads in any order / interleaving.
What is an important motivation for concurrency?
Handling I/O in separate threads to avoid blocking execution of other things
What are the main three statuses of a thread?
RUNNING (on CPU) READY (can be run but isn’t running) BLOCKED (can’t be started)
What is the standard OS library for threads?
pthreads, pthread_create, pthread_exit, pthread_join
How is the state of a thread stored?
It’s stored in a zone called TCB (Thread controll block). Each thread has its own stack.
What are the two basic lock operations on threads?
Lock.acquire() and Lock.release()
What happens if the scheduler runs out of processes to run?
The lowest priority process comes into place: the idle process. This process runs indefinitely and consumes very low power.
How is a process created?
Every process in linux is created by another process. Typically by the fork system call.
How does a program distinguishes whether it’s a child process or a parent process?
The result by the fork system call is 0 in the child and the id of the process in the parent process.
What happens if a thread forks off a process?
Only the thread that called process gets copied.
What is a POSIX/Unix PIPE
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.
What’s the system call for pipes?
pipe.