Program vs Process

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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?

  • Source code
  • A data section
  • Binary code (correct)
  • An executable process

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:

<p>Text Section = Contains executable code Stack = Stores temporary data like function parameters Data Section = Holds global and static variables Heap Section = Dynamically allocated memory</p> Signup and view all the answers

What does the 'Ready' state signify in the context of process states?

<p>The process is loaded into main memory and awaiting CPU time (D)</p> Signup and view all the answers

Processes in the 'Ready' state are maintained in a queue awaiting CPU execution.

<p>True (A)</p> Signup and view all the answers

Which component is responsible for selecting a process from the ready state for execution?

<p>Short-term scheduler (D)</p> Signup and view all the answers

What is the primary function of the dispatcher in process management?

<p>Loading the process selected by the short-term scheduler onto the CPU (C)</p> Signup and view all the answers

The process of saving the context of one process and loading the context of another is known as ______.

<p>context switching</p> Signup and view all the answers

Which scenario does NOT typically trigger context switching?

<p>When a low-priority process enters the ready state (D)</p> Signup and view all the answers

The medium-term scheduler is responsible for managing swapping, which involves moving processes from main memory to disk and vice versa.

<p>True (A)</p> Signup and view all the answers

What is the main purpose of swapping?

<p>To improve the process mix and free up memory (D)</p> Signup and view all the answers

What information is stored in the Process Control Block (PCB)?

<p>process state, program counter, stack pointer, status of opened files, scheduling algorithms, etc.</p> Signup and view all the answers

What is the purpose of the process identification number (PID)?

<p>To uniquely identify each process (C)</p> Signup and view all the answers

Threads within the same process operate in separate memory spaces, ensuring isolation.

<p>False (B)</p> Signup and view all the answers

Which of the following is NOT shared between threads within the same process?

<p>Stack space (C)</p> Signup and view all the answers

Match the following characteristics with either Process or Thread:

<p>Process = Requires more time for creation Thread = switching does not always require OS calls</p> Signup and view all the answers

What is a key advantage of using threads over processes?

<p>Faster context switching (B)</p> Signup and view all the answers

A kernel is NOT responsible for tasks such as disk or memory management.

<p>False (B)</p> Signup and view all the answers

Which of the following is NOT a primary objective of a kernel?

<p>Directly executing user applications (D)</p> Signup and view all the answers

Which type of thread is implemented in the user-level library and does not use system calls for creation?

<p>User Level Thread (ULT) (D)</p> Signup and view all the answers

If one ______ thread causes a page fault, the entire process blocks.

<p>user level</p> Signup and view all the answers

Kernel Level Threads (KLT) are unknown and unmanaged by the kernel, treating them as single-threaded processes.

<p>False (B)</p> Signup and view all the answers

What is a key disadvantage of Kernel Level Threads?

<p>Slow and inefficient operation due to overhead (D)</p> Signup and view all the answers

Distinguish between User Level Threads (ULT) and Kernel Level Threads (KLT):

<p>User Level Thread (ULT) = If one thread blocks, the entire process is blocked Kernel Level Thread (KLT) = Hardware support is needed</p> Signup and view all the answers

Which time represents the total duration a process spends in the ready queue, awaiting execution?

<p>Waiting Time (A)</p> Signup and view all the answers

In a uniprogramming system, the CPU remains busy processing other tasks while a process waits for I/O.

<p>False (B)</p> Signup and view all the answers

Which is NOT a typical objective of process scheduling algorithms?

<p>Increasing the waiting time (A)</p> Signup and view all the answers

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?

<p>Preemptive Scheduling (B)</p> Signup and view all the answers

Non-preemptive scheduling interrupts a process running on the CPU mid-execution.

<p>False (B)</p> Signup and view all the answers

Which scheduling algorithm is also known as 'first come, first served'?

<p>FCFS (B)</p> Signup and view all the answers

The ______ effect in FCFS occurs when a long process blocks shorter jobs, impacting the average wait time.

<p>convoy</p> Signup and view all the answers

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.

<p>False (B)</p> Signup and view all the answers

Which of the following BEST describes Shortest Remaining Time First (SRTF) scheduling?

<p>The preemptive version of SJF scheduling (C)</p> Signup and view all the answers

What is assigned to each process in Round Robin scheduling?

<p>A fixed time quantum (D)</p> Signup and view all the answers

In Priority CPU scheduling, processes with lower numbers generally indicate a lower priority.

<p>False (B)</p> Signup and view all the answers

What happens if two processes have the same arrival time under priority scheduling?

<p>The process is selected that has a lower process number. (A)</p> Signup and view all the answers

What is the key difference between Multilevel Queue Scheduling and Multilevel Feedback Queue Scheduling?

<p>multilevel queue scheduling does not allow processes to move between queues, while multilevel feedback queue scheduling allows processes to move between queues.</p> Signup and view all the answers

Processes in Multilevel Feedback Queue Scheduling are NOT allowed to move between queues.

<p>False (B)</p> Signup and view all the answers

A potential disadvantage of Multilevel Queue Scheduling is that it can suffer from ______.

<p>starvation</p> Signup and view all the answers

What helps determine the decision to move a process from one queue to another in Multilevel Feedback Queue Scheduling?

<p>Characteristics of their CPU bursts. (A)</p> Signup and view all the answers

Flashcards

What is a process?

A program in execution. It's an active entity, created when binary code is run.

What is the Text Section?

The segment of memory containing the program's instructions.

What is the Stack?

Memory segment that holds temporary data like function parameters and local variables.

What is the Data Section?

Memory segment containing global and static variables.

Signup and view all the flashcards

What is the Heap Section?

Memory that is dynamically allocated during the process's runtime.

Signup and view all the flashcards

What is Process state?

The state of a process defined by its current activity.

Signup and view all the flashcards

What is the 'New' process state?

The OS state when the process, is about to be created.

Signup and view all the flashcards

What is the 'Ready' process state?

Process state after creation when the process is loaded into the main memory waiting to run.

Signup and view all the flashcards

What is the 'Run' process state?

Process state when chosen by the CPU, and instructions are executed.

Signup and view all the flashcards

What is the 'Wait' process state?

It is a process state when a process requests I/O access.

Signup and view all the flashcards

What is the Long Term scheduler?

It is a scheduler that brings new processes to the 'Ready State'.

Signup and view all the flashcards

What is the Short Term (CPU) scheduler?

Scheduler responsible for selecting one job from the ready state to be executed.

Signup and view all the flashcards

Who is the Dispatcher?

Loads the process selected by the short-term scheduler onto the CPU.

Signup and view all the flashcards

What is the Medium-term scheduler?

Responsible for suspending and resuming processes.

Signup and view all the flashcards

What is Context Switching?

Saving the context of one process and loading the context of another.

Signup and view all the flashcards

What is Process ID (PID)?

A unique identification number assigned to each process.

Signup and view all the flashcards

What is a Process Control Block (PCB)?

Data structure containing information about a process, used to track its execution status.

Signup and view all the flashcards

What is a Thread?

A path of execution within a process that achieves parallelism.

Signup and view all the flashcards

Process vs. Thread memory?

Threads share memory space; processes have separate memory spaces.

Signup and view all the flashcards

What is the Kernel?

A central component of an operating system that manages operations of memory and CPU time.

Signup and view all the flashcards

What is a User Level Thread(ULT)?

Implemented in the user-level library, not created using system calls.

Signup and view all the flashcards

What is a Kernel Level Thread(KLT)?

Kernel knows and manages the threads.

Signup and view all the flashcards

What is Arrival Time?

Time when the process arrives in the ready queue.

Signup and view all the flashcards

What is Completion Time?

Time at which process completes its execution.

Signup and view all the flashcards

What is Burst Time?

Time required by a process for CPU execution.

Signup and view all the flashcards

What is Turn Around Time?

Time difference between completion time and arrival time.

Signup and view all the flashcards

What is Waiting Time?

Time difference between turnaround time and burst time.

Signup and view all the flashcards

What is preemptive scheduling?

Scheduling is used when a process switches from running state to ready state or from the waiting state to ready state.

Signup and view all the flashcards

What is non-preemptive scheduling?

Scheduling is used when a process terminates, or a process switches from running to the waiting state.

Signup and view all the flashcards

What is FCFS scheduling?

FIFO, also known as first come, first served

Signup and view all the flashcards

What is the convoy effect (FCFS)?

A condition that occurs when many small processes get blocked behind a larger process.

Signup and view all the flashcards

What is Shortest Job First (SJF)?

Selects the waiting process with the smallest execution time to execute next. It is a Greedy Algorithm.

Signup and view all the flashcards

What is Shortest Remaining Time First (SRTF)?

Preemptive version of SJF scheduling.

Signup and view all the flashcards

What is Round Robin scheduling?

Each process is assigned a fixed time(Time Quantum/Time Slice) in cyclic way.

Signup and view all the flashcards

What is Priority scheduling?

Each process is assigned first arrival time (less arrival time process first) if two processes have same arrival time, then compare to priorities (highest process first).

Signup and view all the flashcards

What is Multilevel Queue Scheduling?

Processes are placed in different queues and high priority process are placed in the top level queue.

Signup and view all the flashcards

What is Multi level Feedback Queue Scheduling?

It allows the process to move in between queues, separating processes according to the characteristics of their CPU bursts.

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.

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.

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.

Quiz Team

Related Documents

More Like This

Procurement and Maintenance Program Overview
67 questions
Operating System Basics and Processes
25 questions
Use Quizgecko on...
Browser
Browser