Processes & Threads Flashcards
What are CPU activities called?
- A batch system executes jobs
- A time-shared system had user programs or tasks
- Common term for all processes
What are programs?
- A program is a passive entity, stored on disk (or other media).
waiting to be executed - Once active, we refer to its instantiation as a process
- Single programme: may invoke multiple individual processes
What does Text Segment (Code) store?
- Stores the executable code
What does Data Segment store?
Stores global and static variables
What does the Heap segment do?
Used for dynamic memory allocation at
run time
* Grows upward in memory as more
memory is allocated.
* Shrinks when memory is freed
What is the Stack Segment?
- Temporary data
- Stores function calls, local variables, and return addresses.
- Grows downward in memory.
- Each function call creates a new stack frame.
What are the 5 step that a OS manages New Process?
Typical steps 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
What is the Scheduling Processes aim?
To maximise CPU usage
What are the 4 (Scheduling Processes)
- Job queue (long-term scheduler)
- Ready queue (short-term scheduler)
- Device queue (for each device)
- I/O requests awaiting completion
- Swapped-out queue (medium-term scheduler)
- Management of processes that cannot make progress towards
completion - Free up space for other processes
To manage and control processes, OS must know what?
- Process location
- Process attributes
What is IPC?
Inter-Process Communication (IPC) is a mechanism that
allows processes to communicate and share data.
* Processes run independently and have separate memory
spaces
* IPC enables them to exchange information efficiently.
Why is IPC needed?
Processes often work together - need to share data.
* Some processes depend on each other’s output
* e.g., a producer process creates data, and a consumer process
uses it
* Processes need to synchronise their execution (e.g., avoiding
race conditions)
What are Threads?
A thread or lightweight process is a particular execution
path within a larger process
* They share the process’s resources (memory, files, etc.)
* They have independent execution flows.
Multithreading Benefits
Responsiveness
* May allow a program to continue running even if part of it is blocked or performing
a lengthy operation
Resource sharing
* Processes can only share resources through techniques such as shared memory
and message passing.
* Threads share the memory and resources of the process by default
Economy
* Allocating memory and resources for process creation is costly.
* Threads share the resources of the process. Thus, it is more economical to create
and context-switch threads.
Scalability
* A single thread process can only run single core
* Multi thread process can run in parallel across multiple cores