Operating Systems: Processes and Threads Flashcards

1
Q

What does a batch system do?

A

Execute jobs.

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

What does a time-shared system have?

A

User programs or tasks.

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

What is the common term for all CPU activities?

A

Processes.

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

What is a program?

A

A passive entity, stored on a disk (or other media) waiting to be executed.

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

What do we refer to a program as once it has become active?

A

A process.

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

What is a single program capable of doing?

A

A single program may invoke multiple individual processes.

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

Where is a process held?

A

Memory.

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

What is the structure of a process?

A

Text segment (code).
Data segment.
Heap segment.
Stack segment.

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

What is the text segment.

A

Stores the executable code.

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

What is the data segment?

A

Stores global and static variables.

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

What is the heap segment used for?

A

Used for dynamic memory allocation at run time, growing upwards in memory as more memory is allocated and shrinking when memory is freed.

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

What is the stack segment?

A

Temporary data that stores function calls, local variables, and return addresses. Grows downwards in memory, and each function call creates a new stack frame.

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

What are the states of execution?

A

New.
Running.
Waiting (or blocked).
Ready.
Terminated.

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

What is the new stage of execution?

A

The process is being created.

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

What is the running stage of execution?

A

The instructions are being executed.

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

What is the waiting (or blocked) stage of execution?

A

The process is paused, whilst waiting for some event.

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

What is the termination stage of execution?

A

The execution has been finished.

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

What is the role of the Operating System in managing a new batch job?

A

It manages a batch job control stream and reads the next job when it is ready.

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

How does an interactive log on (user action) lead to process creation?

A

The user logs on to the service, then opens a program or runs a command, which creates a new processor.

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

What type of processes are categorised as OS services?

A

Daemons and background services such as print man ager or SSH agent.

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

Besides new batch jobs and OS services, what is another common mechanism for creating a new process?

A

Processes can be spawned by existing processes.

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

In an Operating System, where does every process originate?

A

From another process (the parent).

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

How does a process hierarchy or “tree” form in an OS?

A

A parent process creates child processes, which in turn creates more processes, forming a tree.

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

What is a PID, and why is it important?

A

A PID, (process identifier), is used to identify and manage processes in an operating system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the three main resource sharing options between parent and child processes?
1. Parent and children share all resources. 2. Children share a subset of the parent's resources. 3. Parent shares none of its resources with the children.
26
What are the two main execution options for parent and child processes?
1. The parent and child execute concurrently. 2. The parent waits until the children terminate.
27
What are the typical steps an OS follows when creating a process?
1. Allocates memory. 2. Assigns a unique process ID (PID): 3. Loads executable code into memory. 4. Sets up the process's execution context - PCB etc. 5. Schedules the process for execution.
28
What does the process scheduler maintain?
The job queue. The ready queue. The device queue. The swapped-out queue.
28
What is the main aim of scheduling processes?
The main aim is to maximise CPU usage.
29
What type of scheduler is the job queue?
The job queue is a long term scheduler.
30
What type of scheduler is the ready queue?
The ready queue is a short term scheduler.
31
What type of scheduler is the device queue?
The device queue is for each device.
32
What type of scheduler is the swapped-out queue?
The swapped-out queue is a medium term scheduler.
33
How does the process scheduler maintain the job queue?
By transitioning jobs from new to ready.
34
How does the process scheduler maintain the ready queue?
From transitioning processes from ready to running.
35
How does the process scheduler maintain the device queue?
I/O requests awaiting completion.
36
How does the process scheduler maintain the swapped-out queue?
By managing processes that cannot make progress towards completion, and freeing up space for other processes.
37
In a single-processor system, how many processes can run concurrently?
Only one process can run at any given time.
38
What must occur when the CPU switches from one process to another?
The system must save the state of the old process and load the saved state for the new process via a context switch.
39
Where is the context of a process stored?
In the Process Control Block (PCB).
40
What is the key drawback of context switching?
Context-switch time is considered overhead because the system does no useful work during the switch.
41
How does the complexity of the OS and PCB affect context switching?
The more complex the OS and PCB, the longer the context switch takes.
42
What factors influence the time taken for a context switch?
It is dependent on the hardware support available.
43
How can some hardware reduce the context-switch overhead?
By providing multiple sets of registers per CPU, allowing multiple contexts to be loaded simultaneously.
44
What are the two key pieces of information that the OS must now to manage and control processes?
The process location and process attributes.
45
How is process management information typically summarised?
In the Process Control Block (PCB).
46
What is the Process Control Block?
A data structure that contains all the information associated with each process.
47
List three core elements contained in a PCB.
Process state, process number, and program counter.
48
What memory-related information is included in a PCB?
Memory limits, and memory management information regarding memory allocated to the process.
49
What file-related detail does a PCB contain?
A list of open files.
50
What register-related information is stored in the PCB?
The contents of all process-centric CPU registers.
51
What scheduling details are found in a PCB?
CPU scheduling information such as priorities and scheduling queue pointers.
52
What accounting information might a PCB include?
Information such as the CPU used, clock time elapsed since the process start, and any time limits.
53
What I/O information is tracked in a PCB?
The I/O devices allocated to the process and the list of open files.
54
What are some causes of process termination? (Name at least three).
Normal termination, time limit exceeded, and memory unavailable.
55
What are some error-related reasons for process termination? (Name two).
Bounds violation and protection error.
56
Name three additional errors or issues that can lead to process termination.
Arithmetic error, invalid instruction, and privileged instruction.
57
What external or user-related factors can result in process termination?
Timeout, I/O failure, data misuse, operator/OS intervention, parent termination, or parent request.
58
What is "swapping" or "suspending" a process in an operating system context?
The act of moving process out of main memory (RAM) into secondary storage (or marking it as suspended), so it is not immediately available for execution.
59
Why might an OS swap or suspend a process?
Memory requirement: Free up main memory for other processes. OS Management: The OS might need to reorganise or manage resources. Interactive requests (e.g., Ctrl + Z in a terminal): User suspends a foreground job. Timing (e.g., period cycle of accounting): Process suspension might be needed for system maintenance. Parent process request: A parent can explicitly suspend its child.
60
What is the consequence of swapping/suspending a process?
The process is not in main memory and therefore is not available for immediate execution (i.e., it cannot be scheduled to run until it is moved back into main memory or resumed).
61
What is inter-process communication (IPIC)?
A mechanism allowing processes to communicate and share data. Since processes run independently with separate memory spaces, IPC provides ways to exchange information efficiently.
62
Why is IPC needed in an operating system?
Processes often need to share data or depend on each other's output. Synchronisation is necessary to avoid race conditions and coordinate actions. It allows for cooperative tasks, such as producer/consumer relationships. It can speed up computation, provide modularity, and improve convenience.
63
What does it mean for processes to "cooperate"?
Cooperating processes share information, possibly run in parallel for speed-up, may be designed modularly to split tasks, and can enhance overall convenience and efficiency of the system.
64
Give an example of processes that require IPC.
A producer process that creates data (e.g., filling a buffer) and a consumer process that reads or processes that data (e.g., emptying a buffer).
65
What are the two primary mechanisms for Inter-process communication?
Message Passing. Shared Memory.
66
How do message passing and shared memory differ fundamentally?
Message Passing: Processes communicate by sending and receiving messages via the kernel (no shared address space required). Shared Memory: Processes directly read/write to a common memory region (the OS sets it up, but user processes control the communication).
67
What is "shared memory" IPC?
An area of memory that multiple processes can access (read/write) directly. This region is set up by the OS but once established, the OS typically does not mediate every access.
68
Who controls the communication in shared memory IPC?
The user processes control the reading and writing to the shared memory region; the OS only sets it up and provides the means for processes to share it.
69
What is the major challenge in shared memory IPC?
Synchronising access to the shared region so that processes do not interfere with one another (avoiding race conditions).
70
Why is synchronization critical when processes share memory?
Without proper synchronization, concurrent reads/writes can result in data inconsistency or corruption (classic race condition scenario).
71
What is message passing in the context of IPC?
A mechanism by which processes send and receive messages, often via the kernel or a messaging facility, without using shared memory.
72
What operations does a typical message-passing IPC facility provide?
send(message): A process places a message into the message queue. receive(message): Another process retrieves a message from the queue.
73
What are the possible sizes of messages in message passing?:
The message size can be fixed (limited length) or variable (can handle different-size messages).
74
What are the key implementation issues to consider in message passing?
Establishing links: How do processes set up communication channels? Multiplicity: Can a link be associated with more than two processes? Number of links: How many links can exist between a pair of processes? Link capacity: What is the maximum number of messages that can be queued? Message size constraints: Is there a fixed or variable limit? Directionality: Is the communication unidirectional or bidirectional?
75
When processes want to communicate via message passing, what must they do first?
Establish a communication link (a channel for messages). Exchange messages using send and receive operations.
76
What happens is a process calls "send" on a full queue in a message-passing system?
Behaviour can vary. It may block the sender until space is available. It may discard messages. It may return an error. All depends on the implementation and link capacity policies.
77
Does the OS manage every single read/write in shared memory IPC?
Typically, no. The OS only sets up the shared region. User processes then read/write directly. The OS does not mediate each operation.
78
Why is process synchronisation central to both shared memory and message passing?
In both cases, processes may need to coordinate the timing/order of access or the sending/receiving of messages to avoid inconsistencies, lost data, or race conditions.
79
How do interactive user actions (like Ctrl + Z) differ from kernel-driven suspensions?
Interactive request: The user explicitly suspends the process from a terminal. Kernel-driven suspensions: The OS decides to suspend processes for reasons like memory constraints, scheduling, timing, or parent requests.
80
Give one reason a parent process might request its child to suspend.
It could be for resource management (limiting CPU/memory usage), debugging (pausing execution to inspect state), or synchronisation with other processes.
81
What is a race condition?
A situation where multiple processes or threads access shared data concurrently, and the final outcome depends on the timing of their execution, leading to unpredictable results.
82
What are the two main types of message passing in terms of synchronisation?
Blocking (synchronous) and non-blocking (asynchronous)
83
What does "blocking" message passing imply?
In blocking (synchronous) message passing, the sender/ receiver may be forced to wait (block) during the send/receive operation.
84
What is a "blocking send"?
A blocking send means the sender is blocked until the message has been received by the receiving process.
85
What is a "blocking receive"?
A blocking receive means the receiver is blocked until a message becomes available.
86
What does "non-blocking" message passing imply?
In non-blocking (asynchronous) message passing, the sender/receiver does not wait. They continue execution immediately after attempting to receive.
87
What is a "non-blocking send"?
A non blocking send allows the sender to send the message and continue execution immediately after sending or attempting to receive.
88
What is a "non-blocking send"?
A non-blocking send allows the sender to send the message and continue execution without waiting for the receiver.
89
What is a "non-blocking receive"?
A non-blocking receive allows the receiver to attempt to receive a message and continue if no message is available, potentially returning a null or similar indicator if no message was present.
90
Which web browser is known for using a multi-process architecture?
Google chrome. Each tab or extension can run its own process to improve stability, security, and responsiveness.
91
What resources does a process typically "own"?
A process owns resources such as memory, files, I/O channels, and other OS-managed assets.
92
What does it mean to say that a process follows a particular "execution path" or "thread of execution"?
Each process has at least one thread that sequences the instructions and defines the order in which they are executed.
93
What is a "thread" or "lightweight process"?
A thread is a single execution path with a larger process. Multiple threads in the same process share the same resources but have independent flow (each has its own program counter, registers, and stack).
94
What resources do threads in the same process share?
Threads within the same process share the process's memory space, files, and other resources.
95
How does a single-threaded process differ from a multithreaded process in terms of execution paths?
Single-threaded: Has only one execution path (one thread). Multithreads: Has multiple concurrent threads, each potentially performing different tasks while sharing the same resources.
96
In a single-threaded process, how many stacks and registers are typically maintained?
There is one stack and one set of registers (PC, CPU registers, etc.) for a single thread.
97
In a multithread process, how many stacks and sets of registers are there?
Each thread has its own stack and register set, but the threads share common code, data, and files of the process.
98
Why are most modern software applications written as multi-threaded applications?
They often perform multiple similar or parallel tasks (e.g., a web server handling multiple requests concurrently) for responsiveness and performance.
99
Give a typical example of a multi-threaded application.
A client-server application where each new client request spawns a new thread on the server side to handle that request, while the main server thread continues listening for more requests.
100
What is the responsiveness benefit of multithreading?
A program can continue to run or respond to the user even if part of it is blocked or performing a lengthy operation, because other threads may remain active.
101
Why is resource sharing easier with threads than with separate processes?
Threads by default share the parent process's memory and resources, whereas processes must use shared memory or message passing to exchange data.
102
How does multithreading improve "economy"?
Creating and context-switching threads is typically less expensive than doing so with full processes, since threads share the process's resources and address space.
103
How does multithreading enable scalability?
On multi-core systems, different threads can run in parallel on separate cores, thus potentially speeding up execution.
104
What does it mean to "identify tasks" in the context of multithreading?
Determining which parts of a program can be divided into separate threads.
105
Why is "balance" important in multithreading?
To ensure that work is distributed equally (or proportionally) among threads so that no single thread is a bottleneck.
106
What is "data splitting" in a multithreading context?
Ensuring each thread has or can access the subset of data it needs, without causing excessive contention or duplication.
107
What is "data dependency", and why must it be addressed in multithreading?
Data dependency refers to situations where one thread's computation depends on data produced by another. Threads must be synchronised correctly to avoid incorrect results or race conditions.
108
Why can testing and debugging be more difficult in a multithreaded program?
Concurrency introduces nondeterministic behaviour (race conditions, timing issues), making it harder to reproduce and diagnose bugs consistently.