Process Management Flashcards

1
Q

Succinctly describe a process.

A

A unit of resource allocation.

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

Succinctly describe a thread.

A

A unit of execution.

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

What’s a major difference between a process and a thread?

A

(Many answers)
Processes are collections of one or more threads.

Processes have a PID; Threads have associated variables.

Processes have Virtual Memory dedicated to them; Threads share memory (by def’n).

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

What’s the C command for getting a process ID?

A

getpid(void). Returns a pid_t.

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

What’s the C command for creating a thread?

A

pthread_create(pthread_t& thread, <attr.s>, void* thread_fn, void* arg);</attr.s>

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

What is a signal?

A

A special event delivered to a process (or many).

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

How can I call a signal?

A

sighandler_t signal(int signum, sighandler_t handler);

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

What makes signals distinct from hardware interrupts?

A

Signals are handled by the OS, and may go through many handlers. Hardware interrupts touch hardware.

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

What is polling?

A

The process of actively checking for events (signals, interrupts) at regular intervals.

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

What is Reentrant & Thread-Safe Code?

A

Code that allows for calling when it’s already running. Does not modify global or static variables, and only uses its own arguments and local variables.

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

What is Parallelism?

A

The process of running multiple threads at the same time using dedicated hardware resources.

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

What is Concurrency?

A

The process of running multiple threads at the same time using shared hardware resources.

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

What’s the major difference between Parallelism and Concurrency?

A

Parallelism is guaranteed to utilize simultaneous execution; Concurrency merely imitates it.

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

Why is multithreading effective?

A

Multi-core systems.

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

TRUE/FALSE: Threads have their own address spaces.

A

FALSE: Threads share the same address space in order to access the heap, any global variables, etc.

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

How can one enable mutual exclusion while multithreading?

A

Mutexes and condition variables.

17
Q

What are CPU Set/Jmp primitives primarily used for?

A

Exception handling.

18
Q

What does setjmp do?

A

Saves the state of the program for later use.

19
Q

What does longjmp do?

A

Jumps to an earlier saved state.

20
Q

What project did we build with setjmp and longjmp? (Project purpose, not number)

A

The scheduler.

21
Q

What is the primary mechanism to create a process in Linux?

A

pid_t fork(void);

22
Q

When running fork, what pid will the child process have?

A

0.

23
Q

TRUE/FALSE: When forking a process, the parent resources will be copied for the child process.

A

TRUE.

24
Q

What is a fork call primarily used for?

A

An execv call.

25
Q

What does a join (waitpid) operation do in relation to forking?

A

Join processes (like waitpid) wait for the child process to complete before completing.

26
Q

What are Linux Pipes?

A

Linux pipes enable communication between processes, and can chain together outputs and inputs.

27
Q

TRUE/FALSE: Memory mapping is another mechanism for inter-process communication.

A

TRUE.

28
Q

What does the Linker do?

A

Connects different process together and into a single executable. Managed by the OS. Creates .so objects.

29
Q

TRUE/FALSE: When managing more processes than cores, the scheduler divides threads and processes among the cores, letting each core concurrently run the processes assigned.

A

FALSE: The scheduler can multiplex the processes, moving threads to different cores over the duration of its running.