Podcast
Questions and Answers
A program in execution is referred to as an active entity, known as a 'process'.
A program in execution is referred to as an active entity, known as a 'process'.
True (A)
When a C++ program is compiled, what is the immediate result?
When a C++ program is compiled, what is the immediate result?
- Source code
- A data section
- Binary code (correct)
- An executable process
Which memory section holds dynamically allocated memory during process execution?
Which memory section holds dynamically allocated memory during process execution?
- Heap Section (correct)
- Text Section
- Data Section
- Stack
Match the process memory sections with their descriptions:
Match the process memory sections with their descriptions:
What does the 'Ready' state signify in the context of process states?
What does the 'Ready' state signify in the context of process states?
Processes in the 'Ready' state are maintained in a queue awaiting CPU execution.
Processes in the 'Ready' state are maintained in a queue awaiting CPU execution.
Which component is responsible for selecting a process from the ready state for execution?
Which component is responsible for selecting a process from the ready state for execution?
What is the primary function of the dispatcher in process management?
What is the primary function of the dispatcher in process management?
The process of saving the context of one process and loading the context of another is known as ______.
The process of saving the context of one process and loading the context of another is known as ______.
Which scenario does NOT typically trigger context switching?
Which scenario does NOT typically trigger context switching?
The medium-term scheduler is responsible for managing swapping, which involves moving processes from main memory to disk and vice versa.
The medium-term scheduler is responsible for managing swapping, which involves moving processes from main memory to disk and vice versa.
What is the main purpose of swapping?
What is the main purpose of swapping?
What information is stored in the Process Control Block (PCB)?
What information is stored in the Process Control Block (PCB)?
What is the purpose of the process identification number (PID)?
What is the purpose of the process identification number (PID)?
Threads within the same process operate in separate memory spaces, ensuring isolation.
Threads within the same process operate in separate memory spaces, ensuring isolation.
Which of the following is NOT shared between threads within the same process?
Which of the following is NOT shared between threads within the same process?
Match the following characteristics with either Process or Thread:
Match the following characteristics with either Process or Thread:
What is a key advantage of using threads over processes?
What is a key advantage of using threads over processes?
A kernel is NOT responsible for tasks such as disk or memory management.
A kernel is NOT responsible for tasks such as disk or memory management.
Which of the following is NOT a primary objective of a kernel?
Which of the following is NOT a primary objective of a kernel?
Which type of thread is implemented in the user-level library and does not use system calls for creation?
Which type of thread is implemented in the user-level library and does not use system calls for creation?
If one ______ thread causes a page fault, the entire process blocks.
If one ______ thread causes a page fault, the entire process blocks.
Kernel Level Threads (KLT) are unknown and unmanaged by the kernel, treating them as single-threaded processes.
Kernel Level Threads (KLT) are unknown and unmanaged by the kernel, treating them as single-threaded processes.
What is a key disadvantage of Kernel Level Threads?
What is a key disadvantage of Kernel Level Threads?
Distinguish between User Level Threads (ULT) and Kernel Level Threads (KLT):
Distinguish between User Level Threads (ULT) and Kernel Level Threads (KLT):
Which time represents the total duration a process spends in the ready queue, awaiting execution?
Which time represents the total duration a process spends in the ready queue, awaiting execution?
In a uniprogramming system, the CPU remains busy processing other tasks while a process waits for I/O.
In a uniprogramming system, the CPU remains busy processing other tasks while a process waits for I/O.
Which is NOT a typical objective of process scheduling algorithms?
Which is NOT a typical objective of process scheduling algorithms?
What scheduling strategy involves allocating a process to a CPU for a limited duration, after which it might be placed back in the ready queue?
What scheduling strategy involves allocating a process to a CPU for a limited duration, after which it might be placed back in the ready queue?
Non-preemptive scheduling interrupts a process running on the CPU mid-execution.
Non-preemptive scheduling interrupts a process running on the CPU mid-execution.
Which scheduling algorithm is also known as 'first come, first served'?
Which scheduling algorithm is also known as 'first come, first served'?
The ______ effect in FCFS occurs when a long process blocks shorter jobs, impacting the average wait time.
The ______ effect in FCFS occurs when a long process blocks shorter jobs, impacting the average wait time.
Shortest Job First (SJF) scheduling is practically feasible for real-time operating systems because the exact burst time of processes is always known in advance.
Shortest Job First (SJF) scheduling is practically feasible for real-time operating systems because the exact burst time of processes is always known in advance.
Which of the following BEST describes Shortest Remaining Time First (SRTF) scheduling?
Which of the following BEST describes Shortest Remaining Time First (SRTF) scheduling?
What is assigned to each process in Round Robin scheduling?
What is assigned to each process in Round Robin scheduling?
In Priority CPU scheduling, processes with lower numbers generally indicate a lower priority.
In Priority CPU scheduling, processes with lower numbers generally indicate a lower priority.
What happens if two processes have the same arrival time under priority scheduling?
What happens if two processes have the same arrival time under priority scheduling?
What is the key difference between Multilevel Queue Scheduling and Multilevel Feedback Queue Scheduling?
What is the key difference between Multilevel Queue Scheduling and Multilevel Feedback Queue Scheduling?
Processes in Multilevel Feedback Queue Scheduling are NOT allowed to move between queues.
Processes in Multilevel Feedback Queue Scheduling are NOT allowed to move between queues.
A potential disadvantage of Multilevel Queue Scheduling is that it can suffer from ______.
A potential disadvantage of Multilevel Queue Scheduling is that it can suffer from ______.
What helps determine the decision to move a process from one queue to another in Multilevel Feedback Queue Scheduling?
What helps determine the decision to move a process from one queue to another in Multilevel Feedback Queue Scheduling?
Flashcards
What is a process?
What is a process?
A program in execution. It's an active entity, created when binary code is run.
What is the Text Section?
What is the Text Section?
The segment of memory containing the program's instructions.
What is the Stack?
What is the Stack?
Memory segment that holds temporary data like function parameters and local variables.
What is the Data Section?
What is the Data Section?
Signup and view all the flashcards
What is the Heap Section?
What is the Heap Section?
Signup and view all the flashcards
What is Process state?
What is Process state?
Signup and view all the flashcards
What is the 'New' process state?
What is the 'New' process state?
Signup and view all the flashcards
What is the 'Ready' process state?
What is the 'Ready' process state?
Signup and view all the flashcards
What is the 'Run' process state?
What is the 'Run' process state?
Signup and view all the flashcards
What is the 'Wait' process state?
What is the 'Wait' process state?
Signup and view all the flashcards
What is the Long Term scheduler?
What is the Long Term scheduler?
Signup and view all the flashcards
What is the Short Term (CPU) scheduler?
What is the Short Term (CPU) scheduler?
Signup and view all the flashcards
Who is the Dispatcher?
Who is the Dispatcher?
Signup and view all the flashcards
What is the Medium-term scheduler?
What is the Medium-term scheduler?
Signup and view all the flashcards
What is Context Switching?
What is Context Switching?
Signup and view all the flashcards
What is Process ID (PID)?
What is Process ID (PID)?
Signup and view all the flashcards
What is a Process Control Block (PCB)?
What is a Process Control Block (PCB)?
Signup and view all the flashcards
What is a Thread?
What is a Thread?
Signup and view all the flashcards
Process vs. Thread memory?
Process vs. Thread memory?
Signup and view all the flashcards
What is the Kernel?
What is the Kernel?
Signup and view all the flashcards
What is a User Level Thread(ULT)?
What is a User Level Thread(ULT)?
Signup and view all the flashcards
What is a Kernel Level Thread(KLT)?
What is a Kernel Level Thread(KLT)?
Signup and view all the flashcards
What is Arrival Time?
What is Arrival Time?
Signup and view all the flashcards
What is Completion Time?
What is Completion Time?
Signup and view all the flashcards
What is Burst Time?
What is Burst Time?
Signup and view all the flashcards
What is Turn Around Time?
What is Turn Around Time?
Signup and view all the flashcards
What is Waiting Time?
What is Waiting Time?
Signup and view all the flashcards
What is preemptive scheduling?
What is preemptive scheduling?
Signup and view all the flashcards
What is non-preemptive scheduling?
What is non-preemptive scheduling?
Signup and view all the flashcards
What is FCFS scheduling?
What is FCFS scheduling?
Signup and view all the flashcards
What is the convoy effect (FCFS)?
What is the convoy effect (FCFS)?
Signup and view all the flashcards
What is Shortest Job First (SJF)?
What is Shortest Job First (SJF)?
Signup and view all the flashcards
What is Shortest Remaining Time First (SRTF)?
What is Shortest Remaining Time First (SRTF)?
Signup and view all the flashcards
What is Round Robin scheduling?
What is Round Robin scheduling?
Signup and view all the flashcards
What is Priority scheduling?
What is Priority scheduling?
Signup and view all the flashcards
What is Multilevel Queue Scheduling?
What is Multilevel Queue Scheduling?
Signup and view all the flashcards
What is Multi level Feedback Queue Scheduling?
What is Multi level Feedback Queue Scheduling?
Signup and view all the flashcards
Study Notes
- Process management involves various concepts related to programs and processes.
Program vs Process
- A process is a program in execution, contrasting with a program, which is static.
- When source code is compiled (e.g., in C or C++), the compiler generates binary code, which is a program.
- Both the original code and the binary code are considered programs.
- When binary code is executed, it becomes a process.
- Processes are active entities, while programs are passive.
- A single program can initiate multiple processes when run concurrently
- For example, opening a .exe file multiple times creates multiple instances: multiple processes.
Process Memory Structure
- A process in memory is divided into sections:
- Text Section: Contains executable code and the current activity, indicated by the Program Counter.
- Stack: Holds temporary data like function parameters, return addresses, and local variables.
- Data Section: Stores global and static variables.
- Heap Section: Provides dynamically allocated memory during runtime.
Examples of Programs and Memory Sections
- Example 1: demonstrates a simple C program to find the maximum of two numbers and shows logical memory allocation.
- Example 2: C program utilizing dynamic memory allocation with malloc, also illustrating memory sections.
- Example 3: Shows passing an array to a function to calculate the elements' sum, demonstrating data handling in memory.
Process States
- A process transitions through different states during execution.
- These states reflect the process's current activity.
- States include:
- New: The process is being created.
- Ready: The process is ready to run, awaiting CPU allocation, and loaded into the main memory.
- Run: The CPU is executing the process instructions.
- Wait (or Block): The process is waiting for an I/O operation or event to occur.
- Complete (or Terminated): The process has finished execution.
- Suspended Ready: The process is moved to a suspended state when the ready queue is full.
- Suspended Block: Occurs when the waiting queue is full.
Process Schedulers
- Process scheduling is managed by the process manager, involving the removal and selection of processes from the CPU based on strategy.
- The three types of process schedulers are:
- Long Term (Job Scheduler): Introduces new processes to the Ready state and controls the degree of multi-programming.
- Balances I/O-bound and CPU-bound processes to increase efficiency.
- Short Term (CPU Scheduler): Selects a process from the ready state to execute, preventing starvation.
- Note that the scheduler chooses only to schedule the process and doesn’t load the process to running. This is when scheduling algorithms apply.
- Dispatcher: Loads the process selected by the short-term scheduler onto the CPU, facilitating Context switching.
- Medium Term: Handles suspending and resuming process, mainly through processes swapping to disk when memory overcommitted.
- Helps maintain balance between I/O-bound and CPU-bound processes and reduces multi-programming.
- Long Term (Job Scheduler): Introduces new processes to the Ready state and controls the degree of multi-programming.
Context Switching
- Context Switching saves the state of one process and loads another, essentially unloading and loading processes between the running and ready states.
- Context switching occurs when:
- A high-priority process enters the ready state.
- An interrupt occurs.
- There is user and kernel-mode switch.
- Preemptive CPU scheduling is used.
Process Table and Process Control Block (PCB)
- While creating a process, the OS performs multiple operations.
- The OS assigns a process ID to track each process individually.
- Due to multi-programming support, OS needs to keep track of all the processes ongoing using the PCB to track process execution.
- PCB contains:
- Memory blocks with process state info, program counter, stack pointer, and file statuses.
- Process State: Records the current process state.
- Process Number: an ID that identifies.
- Program Counter: Stores the address of the next instruction to be executed.
- Registers: CPU registers like accumulators and base registers.
- Memory Limits: Stores memory management system info with page table and segment table.
- Opened Files List: a list of files opened by the process.
- The stored information is saved when switching process states, and the OS updates the PCB to reflect these changes.
Thread in Operating Systems
- A thread is a path of execution within a process, where a process can contain multiple threads.
- Also known as a "lightweight process," achieving parallelism by dividing processes into multiple threads.
- For example, tabs in a browser or formatting and input processing in MS Word are managed as individual threads.
Process vs Thread
- Threads within the same process share memory space.
- Processes run in separate memory spaces.
- Threads share code, data sections, and OS resources, like files and signals.
- Both processes and threads have their own program counter, register set, and stack space.
Differences Between Processes and Threads
- Process: Means any program in execution.
- Thread: Means segment of a process.
- Processes take a longer time to terminate compared to threads.
- Process creation takes longer.
- Context switching takes more time for processes.
- Processes are isolated meaning thread share memory.
- Processes are heavy weight, whereas threads are light weight.
- Process switches use interfaces in operating system while thread switches do not.
Advantages of Threads over Processes
- Threads provide faster context switching compared to processes.
- Multiple threads effectively enhance the utilization of multiprocessor systems, making processes execute faster.
- Code, data, and files can be shared among the threads
- Note that stack and registers can't be shared, each thread has its own stack and registers.
- Threads share a common address space, hence better communication.
- Dividing tasks into threads enhances the throughput of the system.
Kernel in Operating Systems
- The Kernel is the central component of an operating system which manages memory, CPU time and hardware.
- It acts as a bridge between applications and hardware using inter-process communication.
- It decides which process should be allocated to the processor and be kept in the main memory.
Objectives of the kernel
- Establishing communication between the application and the hardware.
- Decide state of incoming processes.
- Control disk and memory management.
- Control Task Management.
Thread Types
- There are two types of threads:
- User Level Thread
- Kernel Level Thread
User Level Threads (ULT)
- Implemented in user-level libraries.
- Thread switching does not involve OS calls or interrupt the kernel.
- Kernel does not know about the users so manages it as a single threaded process.
- ULT advantages: - Simpler representation since limited to program counter, registers and stack space. - Simple and fast to create.
- ULT disadvantages: - Coordination among threads is restricted. - A page fault can block over the entire process.
Kernel Level Threads (KLT)
- The kernel knows and manages the threads.
- Kernel itself has a master thread table, instead of having a process thread table for all the threads in the system. - System calls create and manage threads
- KLT advantages:
- Good for applications that frequently need to block.
- KLT disadvantages:
- Slow and inefficient.
- It is an overhead and requires thread control.
User Level Threads (ULT) vs Kernel Level Threads (KLT)
- ULT are are implemented by users while KLT are implemented by OS.
- ULT switch time less whereas KLT has higher switch time.
- Implementation easy for ULT and complicated for KLT.
- Kernel threads are designed as thread independent, so they continue execution and provide better concurrency.
CPU Scheduling
- Scheduling of processes/work is the way to ensure finishing work on time.
- Key process times:
- Arrival Time: the time when a process arrives in a ready queue.
- Completion Time: The time at which the process completes the execution.
- Burst Time: The time required for CPU execution. -Turn Around Time (TAT): the difference between completion and arrival. (TAT = Completion Time – Arrival Time).
- Waiting Time: the difference between the turn around time and the burst time.
CPU Scheduling Needs
- A typical process uses I/O time and CPU time.
- If multi-programming is not used, CPU is free time is wasted.
- Multi programming helps processes use the CPU while waiting for I/O.
Process Scheduling Algorithm Objectives
- Objective is to maximize CPU utilization and fair allocation, maximizing the amount of processes that can complete execution per time unit, fairness, and fast execution.
Preemptive Scheduling
- A process’s ability to execute is paused for the resources that are available and then returned to the ready queue if the process has CPU execution remaining.
- The process waits to execute until it receives the next chance.
Non-Preemptive Scheduling
- A process terminates only when the process releases what is allocated or is stopped.
FCFS CPU Scheduling
- Given n processes with their burst times, the task is to find average waiting time and average turn around time using FCFS scheduling algorithm.
- also known as first come, first served (FCFS), is the simplest scheduling algorithm.
- processes are added to the ready queue based on order they arrive in.
- the process the first arrives is executed first, next will continue after it the first fully executes.
- the process the first arrives is executed first.
- The arrival time here is assumed to be all "0" in the ready states for all processes.
FCFS Convoy Effect
- the burst time has a high impact.
Shortest Job First (SJF) CPU Scheduling
- This algorithm picks the waiting process that has the smallest execution time to execute next.
- SJF is a non-preemptive algorithm.
- Having a minimum average waiting among all scheduling algorithms.
- may cause starvation if a process is repeatedly chosen.
Shortest Remaining Time First (SRTF) CPU Scheduling
- This is the preemptive version.
- At the arrival of every process the short term scheduler looks and makes decisions to choose between available processes.
Round Robin (RR) Scheduling
- Process has assigned time to each process that is assigned via the time quantum.
- Specifically designed for the time-sharing system
- It provides interrupt for running processes that execute longer that assigned, and processes get added to the tail of ready queue.
- Specifically designed for the time-sharing system
Priority CPU Scheduling
- A non-preemptive algorithm, and commonly found in batch systems.
- It is assigned first arrival time, and if two processes have equal arrival time, it is then compared to see priorities based on highest amount process first and repeated until processes are executed.
Multilevel Queue Scheduling
- processes are placed in the queues based on amount of priority.
- the high priority processes are placed at the top level queue.
- Processes are only scheduled in the lower lever queues after the completion.
- It may be subject to process starvation.
Multi Level Feedback Queue Scheduling
- The processes can be between the queues. - It helps separate based on the specific characteristics of the CPU Bursts. - It helps separate based on the specific characteristics of the CPU Bursts.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.