Processes, LDEs & Threads Flashcards

(71 cards)

1
Q

What is the virtualization of the CPU a motivation for?

A

Threads & processes

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

Time sharing

A

Running one program for a little while, then running another one, and so forth

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

What illusion does time sharing promote?

A

The illusion that many virtual CPUs exist

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

What is the consequence of time sharing promoting the illusion that many virtual CPUs exist?

A

Each program believes that it is using the CPU alone

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

Program/Executable file

A

A static entity stored on disk

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

Process

A

Active object that’s an abstraction of the CPU / A running program

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

What initiates a process?

A

Users / the system

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

⭐️ A program becomes a process when…

A

it is selected to execute, loaded into memory & has address space generated for it

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

Loading

A

Takes on-disk program and reads it into the address space of process

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

⭐️ What does a process consist of?

A

Address space that consists of:
Trampoline
Trapframe
Heap
Stack
Code
Data
Registers: PC, general purpose, stack pointer

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

What does the address space that a process consists of contain?

A

Memory that the process can address

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

What does the trampoline and trapframe that a process consists of do?

A

Implement transition in & out of kernel space. enable access to privileged kernel services from the user space

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

⭐️ What does the stack that a process consists of contain?

A

Temporary data

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

⭐️ What do the registers that a process consists of contain?

A

Program Counter, general purpose & stack pointer

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

Program Counter (PC)

A

Tells us which instruction the program will execute next

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

Stack pointer

A

Manage the stack for function parameters, local variables and return addresses

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

⭐️ What does the data that a process consists of contain?

A

Global variables

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

⭐️ What does the heap that a process consists of contain?

A

Dynamically allocated structures

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

Where is relevant information for a process stored?

A

Process Control Block (PCB)

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

What are the three most important things stored about a process in a PCB?

A

Process ID
State
Parent process

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

⭐️ What are the different process states?

A

READY
RUNNING
BLOCKED
ZOMBIE

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

⭐️ READY

A

The state a process is in when it’s ready to run and pending for running

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

⭐️ RUNNING

A

The state a process is in when it’s being executed by the OS, and using the CPU

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

⭐️ BLOCKED

A

The state a process is in when it’s suspended due to other events, e.g. IO request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
⭐️ ZOMBIE
The state a process is in when it's completed execution but still has an entry in the system
26
Why do we have the ZOMBIE state?
For a parent process to check the state of a child process
27
SCHEDULED
A process that's moved from READY to RUNNING
28
DESCHEDULED
A process that's moved from RUNNING to READY
29
What do process APIs do?
Manipulate processes
30
CREATE
When a process API creates new processes
31
WAIT
When a process API waits for a process to stop running
32
DESTROY
When a process API destroys the processes forcefully
33
STATUS
When a process API obtains information about a process
34
OTHERS
When a process API suspends/resumes a process
35
⭐️ What does process creation rely on in a Unix-like OS?
fork() and exec(), due to process creation relying on a parent / calling process
36
⭐️ fork()
Creates a new process and clones its parent process
37
⭐️ exec()
Allows a child to break free from its similarity to its parent and execute an entirely new program / Overwrites the created process with a new program
38
⭐️ What does exec() take as input arguments?
Command & arguments (argv)
39
⭐️ Does exec() return?
No, unless there are errors.
40
⭐️ does fork() take any arguments?
No
41
Which processes continue to execute the instruction following a fork()?
Both the parent and the child process
42
⭐️ What does the following return value from a fork() system call indicate: non-zero PID
Return value of the parent process
43
⭐️ What does the following return value from a fork() system call indicate: zero
Return value to the child process
44
⭐️ What does the following return value from a fork() system call indicate: - 1
An error/failure occurred when creating a new process
45
⭐️ What are the two differences between a parent and a child process?
PID and memory addresses
46
⭐️ wait()
Allows a parent to wait for its child to complete execution
47
⭐️ What does wait() return?
process ID of the child
48
⭐️ What does the shell consist of?
fork() + wait() + exec()
49
⭐️ Why do we use fork() + exec()?
- Maintains the shell structure - Makes IO redirection and pipe possible
50
IO redirection
Changing the output from the terminal
51
⭐️ Pipe
a communication method between two processes
52
⭐️ Why do we have processes?
Makes it possible for us to write applications that fully utilize many cores
53
Trap instruction
Simultaneously jumps into the kernel and raises the privilege level to kernel mode
54
Return-from-trap instruction
Returns into the calling user program while simultaneously reducing the privilege level back to user mode
55
Context switch
When the OS switches processes
56
⭐️ Why do we use threads?
To enable inter-process communication & avoid high communication overhead
57
⭐️ What are threads?
Lightweight processes that share the same address space (if they're part of the same process)
58
⭐️ What do threads of the same process share?
The same address space
59
How do threads of the same process communicate?
Through the shared address space
60
What do multiple threads within a process share?
Process ID Address space Open files Current working directory Other resources
61
⭐️ Each thread has its own:
Thread ID (TID) Set of registers: PC & stack pointer Stack for local variables & return addresses
62
⭐️ What are the pros of threads?
Efficient & fast resource sharing Efficient utilization of many CPU cores with only 1 process Less context switching overheads
63
⭐️ What is the con of threads?
Reliability
64
What is a P thread?
a POSIX thread with an API that specifies the behavior of the thread library
65
What is a process in a OS?
A running program with an address space
66
What do we use process APIs for?
Creating and managing processes
67
What are threads?
Lightweight processes
68
⭐️ Which of the following isn't shared by threads? Program Counter Stack Both Program Counter & stack None of the above
Both Program Counter & stack
69
⭐️ Thread synchronization is required because... 1. All threads of a process share the same address space 2. All threads of a process share the same global variables 3. All threads of a process can share the same files 4. All of the above
4. All of the above
70
⭐️ What operations can move a process to the ready state? 1. A process is launched 2. A process is preempted by another 3. A process issued an I/O request and the I/O request is not yet completed
1, 2
71
⭐️ If a process P creates multiple threads, which of the following is not shared among them? 1. The code section of process P 2. The stack registers of threads 3. The open files of process P 4. The global variables of process P
2. The stack registers of threads