Single CPU Systems: Processes and Threads

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In the context of operating systems, what is the primary difference between a 'program' and a 'process'?

  • A program is a unit of work submitted by a user, while a process is a program in execution. (correct)
  • A program requires resources to perform functions, while a process does not.
  • A program is an active entity, while a process is inactive.
  • There is no difference; the terms are interchangeable.

Which of the following best describes the role of the 'Job Scheduler' in processor management?

  • It manages the process queue and determines execution steps.
  • It determines which job gets CPU resources and for how long.
  • It handles interrupt processing and recognizes process termination
  • It selects incoming jobs from a queue and places them in the process queue, deciding on job initiation criteria. (correct)

Why is balancing I/O interaction and computation important for a Job Scheduler?

  • To reduce the number of interrupts.
  • To prioritize CPU-bound jobs over I/O-bound jobs.
  • To ensure that all jobs receive equal processing time.
  • To maximize the utilization of system resources and keep most components busy. (correct)

What is the key function of the 'Process Scheduler'?

<p>To determine which job gets CPU resources and for how long. (B)</p>
Signup and view all the answers

Which of the following is a characteristic of an I/O-bound job?

<p>Performs lots of I/O operations with many brief CPU cycles and long I/O cycles. (A)</p>
Signup and view all the answers

What is the primary purpose of the Process Control Block (PCB)?

<p>To manage a large amount of data for each active process in the system. (B)</p>
Signup and view all the answers

Which of the following pieces of information would you expect to find in a Process Control Block (PCB)?

<p>Processor status information, register contents, and process priority. (A)</p>
Signup and view all the answers

What role do queues play in process management, and how are they related to Process Control Blocks (PCBs)?

<p>Queues use PCBs to track jobs, containing all necessary job management processing data. (A)</p>
Signup and view all the answers

What is the purpose of a CPU context switch?

<p>To save the processing information of an interrupted job and load the information of a new job. (D)</p>
Signup and view all the answers

In a multiprogramming environment, what is the primary pre-scheduling task of the operating system?

<p>To resolve system limitations related to finite resources and resource sharing. (D)</p>
Signup and view all the answers

Which of the following actions would best contribute to maximizing system throughput in a process scheduling policy?

<p>Running as many jobs as possible in a given amount of time while minimizing overhead. (D)</p>
Signup and view all the answers

What is a potential problem if a job claims the CPU for a very long time before issuing an I/O request, and what is a common corrective measure?

<p>The problem is an unacceptable system imbalance; the corrective measure is to use an interrupt to suspend the job. (B)</p>
Signup and view all the answers

What is the key difference between preemptive and non-preemptive scheduling policies?

<p>Non-preemptive scheduling executes the process until completion, while preemptive scheduling can be interrupted by the OS to favor another process. (A)</p>
Signup and view all the answers

Which scheduling algorithms are classified as preemptive?

<p>Shortest Remaining Time (SRT), Round robin, Earliest deadline first (EDF) (A)</p>
Signup and view all the answers

What is a disadvantage of First-Come, First-Served (FCFS) scheduling?

<p>Its average turnaround time varies and is seldom minimized. (B)</p>
Signup and view all the answers

Under what conditions is the Shortest Job Next (SJN) algorithm considered optimal?

<p>When all jobs are available at the same time, and CPU estimates are available and accurate. (B)</p>
Signup and view all the answers

How does Priority Scheduling handle jobs with equal priority in the ready queue?

<p>It uses the First-Come, First-Served (FCFS) policy. (B)</p>
Signup and view all the answers

Which method would a Processor Manager most likely use to assign a lower priority to a job?

<p>Jobs requiring large amounts of memory, or many peripheral devices. (D)</p>
Signup and view all the answers

What is a key characteristic of the Shortest Remaining Time (SRT) scheduling algorithm that distinguishes it from Shortest Job Next (SJN)?

<p>SRT involves more overhead due to monitoring CPU time and context switching, making it preemptive, and SJN is non-preemptive. (D)</p>
Signup and view all the answers

What is the primary purpose of the time slice (quantum) in the Round Robin scheduling algorithm?

<p>To distribute the processing time equitably among all ready processes. (B)</p>
Signup and view all the answers

What happens if the time quantum in Round Robin is too large (larger than most CPU cycles)?

<p>The algorithm reduces to a First-Come, First-Served (FCFS) scheme. (B)</p>
Signup and view all the answers

What is one of the general rules of thumb for determining the best quantum time size in Round Robin scheduling?

<p>It should be long enough for 80% of CPU cycles to complete and at least 100 times longer than the context switch time. (A)</p>
Signup and view all the answers

What is a key characteristic of multiple-level queue scheduling algorithms?

<p>They categorize processes by some characteristic and can use other policies in conjunction. (C)</p>
Signup and view all the answers

Which of the following describes how multiple-level queues might be implemented in a hybrid environment?

<p>CPU-bound jobs are in one queue, and I/O-bound jobs are in another queue. (A)</p>
Signup and view all the answers

Which of the following best describes the Earliest Deadline First (EDF) scheduling algorithm?

<p>A dynamic priority algorithm that addresses critical processing requirements of real-time systems by adjusting job priorities. (D)</p>
Signup and view all the answers

Why might it be impossible to predict job throughput when using the Earliest Deadline First (EDF) algorithm?

<p>Because EDF is a changing priority nature. (D)</p>
Signup and view all the answers

A program attempts to divide a number by zero. What type of interrupt is likely to be triggered?

<p>Internal interrupt, specifically an illegal arithmetic operation interrupt. (B)</p>
Signup and view all the answers

Which of the following events would most likely trigger an I/O interrupt?

<p>A READ or WRITE command is issued. (B)</p>
Signup and view all the answers

Following the detection of a non-recoverable error, what is the typical sequence of steps taken by an interrupt handler?

<p>Describe the interrupt type, save the state of the interrupted process, process the interrupt, resume normal operation. (D)</p>
Signup and view all the answers

What is the purpose of defining and storing the 'type of interrupt' in the interrupt handler sequence?

<p>To provide information that can be passed on to the user as an error message, aiding in debugging and problem-solving. (A)</p>
Signup and view all the answers

A program attempts to access a protected memory location. What type of interrupt is likely to be triggered?

<p>Illegal job instruction interrupt. (A)</p>
Signup and view all the answers

What is the relationship between process states and CPU/processor scheduling?

<p>CPU / Processor Scheduling Determining which process in the ready state should be moved to the running state. (D)</p>
Signup and view all the answers

A job transitions from the Waiting State to Ready State. Which event most likely caused this transition?

<p>Completion of an I/O operation. (B)</p>
Signup and view all the answers

In the context of process scheduling, what does "Turnaround time" refer to?

<p>The amount of time when process arrives in the ready state the first time and when it exits the running state for the last time. (A)</p>
Signup and view all the answers

What are the process scheduling algorithms?

<p>First-Come First-Served, Shortest Job Next, Priority Scheduling, Shortest Remaining Time, Round Robin, Multiple-Level Queues and Earliest Deadline First. (D)</p>
Signup and view all the answers

Flashcards

What is a program (job)?

A program is a passive unit, like a file stored on a disk, representing a unit of work submitted by a user.

What is a process (task)?

A process (task) is an active entity representing a program in execution, requiring resources like the processor and registers.

What is process management?

Process management involves keeping track of processes and their states within the system.

What is a thread?

A thread is a portion of a process that runs independently.

Signup and view all the flashcards

What is the Processor (CPU)?

The processor, or CPU, performs calculations and executes programs.

Signup and view all the flashcards

What is a Multiprogramming environment?

A multiprogramming environment involves multiple processes competing to be run by a single processor, requiring fair and efficient CPU allocation.

Signup and view all the flashcards

What is Multitasking?

Multitasking is when one user runs many programs simultaneously, requiring resources to be shared among them.

Signup and view all the flashcards

What is an interrupt?

An interrupt is a call for help that activates a higher-priority program.

Signup and view all the flashcards

What is a Context Switch?

A context switch involves saving job processing information when interrupted.

Signup and view all the flashcards

What is Job Scheduler?

The Job Scheduler is a higher-level scheduler responsible for job scheduling responsibilities and job initiation based on certain criteria, managing the flow of jobs into the system.

Signup and view all the flashcards

What is a Process Scheduler?

The Process Scheduler is a lower-level scheduler handling process scheduling responsibilities, determining execution steps, and scheduling based on certain criteria, focusing on the execution of processes.

Signup and view all the flashcards

Job Scheduler functions?

Job scheduling involves selecting incoming jobs from a queue, placing them in a process queue, and deciding on job initiation criteria.

Signup and view all the flashcards

What is the Goal of Job Scheduling?

The goal of job scheduling is to sequence jobs efficiently, balance I/O interaction and computation, and keep most system components busy most of the time.

Signup and view all the flashcards

What are Process Scheduler functions?

The Process Scheduler determines which job gets CPU resources, decides interrupt processing, determines queues for process movement, and recognizes process conclusion/termination.

Signup and view all the flashcards

What is an I/O-bound job?

An I/O-bound job performs many I/O operations with brief CPU cycles and long I/O cycles.

Signup and view all the flashcards

What is a CPU-bound job?

A CPU-bound job performs lots of computation with long CPU cycles and shorter I/O cycles.

Signup and view all the flashcards

What is CPU / Processor Scheduling?

CPU/Processor Scheduling determines which process in the ready state should be moved to the running state.

Signup and view all the flashcards

What is a Process Control Block (PCB)?

A Process Control Block (PCB) is a data structure in RAM that stores data for each active process.

Signup and view all the flashcards

Who maintains the PCB?

The operating system (OS) maintains one PCB for each process.

Signup and view all the flashcards

What is a Process ID?

A Process ID is a unique identifier for each process.

Signup and view all the flashcards

What is Processor status information?

Processor status information indicates the current state of the job (e.g., HOLD, READY, RUNNING, WAITING).

Signup and view all the flashcards

What is Processor state information?

Processor state information contains all information needed to indicate the current state of the job. E.g. Process Status Word, register contents, main memory info, process priority, resources

Signup and view all the flashcards

What is Accounting?

Accounting contains information used for billing purposes and performance measurement, as well as what kind of resources the job used and for how long, e.g. account number, amount of CPU time, amount of output

Signup and view all the flashcards

What are Job PCBs?

Job PCBs are created when the Job Scheduler accepts a job, updated as the job executes, track jobs using queues, and contain all necessary job management processing data.

Signup and view all the flashcards

How are PCBs and Queues related?

Queues use PCBs to track jobs, similar to customs officials reviewing passports to track international visitors.

Signup and view all the flashcards

What is Context Switch?

Saving job processing information when interrupted is called a context switch

Signup and view all the flashcards

Resource limitations in OS?

Finite number of resources, some of which cannot be shared once allocated (printers); operator intervention before reassigning resources (tape drives).

Signup and view all the flashcards

What is CPU utilization?

CPU utilization aims to keep the CPU as busy as possible.

Signup and view all the flashcards

What is Turnaround time?

Turnaround time is the amount of time when a process arrives in the ready state the first time and when it exits the running state for the last time.

Signup and view all the flashcards

What is Throughput?

Throughput is the number of processes that complete their execution per time unit.

Signup and view all the flashcards

What is Waiting time?

Waiting time is the amount of time a process has been waiting in the ready queue.

Signup and view all the flashcards

What is Response time?

Response time is the amount of time it takes from when a request was submitted until the first response is produced (for time-sharing environment).

Signup and view all the flashcards

What are the Good process scheduling policy criteria?

Good process scheduling policy criteria should maximize throughput, minimize response time, and minimize turnaround time.

Signup and view all the flashcards

What Ensures fairness?

A process scheduling policy can minimize waiting time, maximize CPU efficiency, and ensure fairness for all jobs.

Signup and view all the flashcards

What causes system imbalance?

If a job claims the CPU for a very long time before issuing an I/O request, it can lead to a buildup in the READY queue and empty I/O queues, creating unacceptable system imbalance.

Signup and view all the flashcards

Use case for Interrupts?

Used by Process Scheduler upon predetermined expiration of time slice

Signup and view all the flashcards

What is Non-preemptive scheduling?

Non-preemptive scheduling is when the currently executing process gives up the CPU voluntarily.

Signup and view all the flashcards

What is Preemptive scheduling?

Preemptive scheduling is when the OS decides to favor another process, preempting the currently executing process.

Signup and view all the flashcards

How many algorithm types is there?

They're six main scheduling algorithm types: First-come, first-served (FCFS); Shortest job next (SJN); Priority scheduling; Shortest remaining time (SRT); Round robin; Multiple-level queues; Earliest deadline first (EDF)

Signup and view all the flashcards

Study Notes

Overview

  • Processor management is examined within the context of single CPU systems.
  • The concepts can be applied to multi-CPU systems, with a scheduler coordinating each CPU.
  • Multiple processor and multi-core systems are not the focus.
  • A program is an inactive unit, such as a file stored on a disk.
  • A program is considered a job when submitted by a user.
  • A process refers to a program in execution.
  • A process is an active entity requiring resources.
  • Process Management keeps track of processes and their states.
  • A thread is a portion of a process that runs independently.
  • The Processor or CPU performs calculations and executes programs.
  • In a multiprogramming environment, multiple processes compete for a single CPU.
  • This requires fair and efficient CPU allocation for each job.
  • Multitasking involves one user running many programs.
  • Multitasking requires resources to be shared.
  • An interrupt is a call for help which activates a higher-priority program.
  • Context switching saves job processing information for interrupted processes.

Scheduling Sub-managers

  • The Processor Manager consists of two sub-managers: the Job Scheduler and the Process Scheduler.
  • The Job Scheduler is a high-level scheduler responsible for job scheduling and initiation.
  • The Process Scheduler is a lower-level scheduler with process scheduling responsibilities, determining execution steps.
  • Job Scheduler’s functions include selecting incoming jobs, placing them in the process queue, and deciding on initiation criteria.
  • The goal of job scheduling is to sequence jobs, balance I/O interaction and computation, and keep most system components busy.
  • Process Scheduler functions involve determining which job gets CPU resources, deciding interrupt processing, and managing process movement during execution.
  • The Process Scheduler recognizes process conclusion or termination

Process Scheduling

  • Programs alternate between CPU and I/O cycles, varying in frequency and duration.
  • There are general program tendencies: I/O-bound jobs and CPU-bound jobs.
  • I/O-bound jobs perform many I/O operations with brief CPU cycles and long I/O cycles
  • CPU-bound jobs perform lots of computation with long CPU cycles and shorter I/O cycles.

Process States

  • CPU/Processor Scheduling determines which process in the ready state moves to the running state.
  • States include Waiting, Ready, Running, New and Terminated
  • Many processes can be in the ready state.
  • Only one process can be in the running state at any time.
  • A typical job changes status as it moves through the system via Hold State, Ready State, Running State, Waiting State and Finished.

Process Control Block (PCB)

  • The operating system manages a large amount of data for each active process.
  • Data is stored in RAM within a data structure called a Process Control Block (PCB).
  • The OS maintains one PCB for each process.

Process Control Block Attributes

  • The PCB includes Process ID (unique), Processor status information, Processor state information, and Accounting.
  • Processor status includes the current state of the job (HOLD, READY, RUNNING, WAITING).
  • Processor state information indicates the current state of the job, e.g. Process Status Word, register contents, main memory information, process priority, resources.
  • Accounting provides billing and performance data and information about what resources the job used.
  • Job PCBs are created and updated by the Job Scheduler.
  • Queues use PCBs to track jobs, containing all necessary job management processing data
  • PCBs are linked to form queues.
  • PCBs require orderly management of queues that is determined by process scheduling policies and algorithms.
  • Queues use control blocks to track jobs like customs officials review passports for international visitors.
  • Control blocks contain data needed by the OS to manage job processing.
  • Progress is noted in the control block so interrupted processes can be resumed.

CPU Context Switch

  • There is only one CPU and therefore only one set of CPU registers.
  • The registers contain the values for the currently executing process.
  • Each time a process is moved to the running state:
    • Register values for the currently running process are stored into its PCB.
    • Register values of the new running state are loaded into the CPU.
    • This exchange of information is called a context switch.

Process Scheduling Policies

  • A multiprogramming environment means more jobs than resources at any given time.
  • The operating system must resolve three system limitations: finite resources, non-shareable resources (printers), and resources requiring operator intervention (tape drives).

Important Definitions

  • CPU Utilization: keep the CPU as busy as possible.
  • Turnaround time: amount of time from when a process arrives in the ready state for the first time to when it exits the running state for the last time.
  • Throughput: the number of processes that complete their execution per time unit.
  • Waiting time: amount of time a process has been waiting in the ready queue.
  • Response time: amount of time from when a request was submitted until the first response is produced.

Good Process Scheduling Policy Criteria

  • Maximize throughput by running as many jobs as possible per unit time
  • Minimize overhead and use resources efficiently.
  • Minimize response time by reducing elapsed time for operations and improving user experience.
  • Minimize turnaround time to quickly execute processes and move jobs through the system.
  • Minimize waiting time by moving jobs out of the READY queue quickly.
  • Maximize CPU efficiency to keep the CPU busy.
  • Ensure fairness by giving every job equal CPU and I/O time.
  • The final policy decision lies with the system designer or administrator.
  • A problem arises when a job claims CPU for a long time before issuing an I/O request.
    • The READY queue builds up and I/O queues are emptied, creating an imbalance.
  • A corrective measure is to use interrupts to suspend job activity and reschedule the job into READY queue.
  • Two types of scheduling policies: Preemptive and Non-preemptive

Scheduling Policies: Non-Preemptive

  • Scheduling where the currently executing process gives up the CPU voluntarily.
  • Once allocated, the process keeps the CPU until it exits or switches to the waiting state.

Scheduling Policies: Preemptive

  • Scheduling where the OS chooses to favor another process, preempting the current one
  • It transfers CPU to another job and is used in time-sharing environments.

Process Scheduling Algorithms

  • The six algorithm types: First-come, first-served (FCFS), Shortest job next (SJN), Priority scheduling, Shortest remaining time (SRT), Round robin, Multiple-level queues and Earliest deadline first (EDF).
  • Current systems emphasize interactive use and response time using preemptive policies.

First Come First Served (FCFS)

  • Non-preemptive
  • Jobs are handled based on arrival time.
  • Simplicity is ensured through first-in, first-out (FIFO) queue implementation.
  • It is suited for batch systems but unacceptable in interactive systems due to unpredictable turnaround time.
  • Average turnaround time varies.

Shortest Job Next (SJN)

  • Non-preemptive
  • Jobs are handled based on length of CPU cycle time.
  • Easy implementation for batch environment since CPU time requirements are known.
  • It doesn't work for interactive systems.
  • It ensures all jobs are available at the same time and that CPU estimates are available and accurate.

Priority Scheduling

  • Non-preemptive
  • It can ensure preferential treatment for important jobs and highest priority programs are processed first.
  • Jobs run without interrupts until CPU cycles are completed or a natural wait occurs.
  • If READY queues contain jobs of equal priority, FCFS policy is used within that priority.
  • System administrators or Processor Managers use different methods of assigning priorities, e.g., memory requirements, device number and CPU time.

Shortest Remaining Time (SRT)

  • Preemptive version of SJN.
  • Processor allocated to job closest to completion.
  • It is best suited for batch environments to give shorter jobs priority.
  • Requires advance CPU time knowledge and cannot be implemented in interactive systems.
  • More overhead than SJN because the system monitors CPU time and performs context switching.

Round Robin

  • A preemptive algorithm.
  • Distributes processing time equitably among all ready processes.
  • Establishes a particular time slice (quantum) for each process.
  • The time quantum size is crucial.
  • The CPU is equally shared among all active processes and not monopolized by one job.
  • It is used in interactive systems.
  • Time quantum size:
    • Crucial to system performance
    • Varies from 100 ms to 1-2 seconds

Considerations for the Round Robin algorithm

  • Efficiency depends on time quantum size in relation to the average CPU cycle.
  • If the quantum is too large response time suffers, and it reduces to FCFS.
  • If Quantum is too small throughput suffers, context switching occurs as well as job execution slows down.
  • Overhead will be dramatically increased and information has to be saved in the PCB
  • The best quantum time size depends on the system.
    • Interactive systems focus on response time
    • Batch systems focus on turnaround time.
  • General rules of thumb for the Round Robin algorithms
    • Be long enough for 80% of CPU cycles to complete
    • At least 100 times longer than context switch time requirement

Process Scheduling Algorithms: Preemptive vs Non-Preemptive

  • First-Come, First-Served: Non-preemptive
  • Shortest Job Next: Non-preemptive
  • Shortest Remaining Time: Preemptive
  • Round Robin: Preemptive

Multiple-Level Queues

  • Characterizes process-categorizing scheduling algorithms that can be used in conjunction with other policies.
  • Processes can be categorized by memory size, process type, response time, externally assigned priorities, etc.
  • Divides the ready queue into separate queues to which processes are assigned so that each queue is associated with one particular scheduling algorithm
  • Interactive processes can use Round Robin, while background processes use FCFS and SRT.

Characteristics of Multiple-Level Queues

  • It is not really a separate scheduling algorithm and can work in conjunction with other schemes and systems.
  • Systems can group jobs according to common characteristics such as priority or whether or not the jobs are CPU bound or IO Bound.
    • Priority-based algorithms are categorized with different queues for each priority level
    • CPU-bound jobs in one queue and I/O-bound jobs in another queue.
    • Hybrid environments categorize Batch jobs in background queue and Interactive jobs in foreground queue.
  • Generally a scheduling policy is based on a predetermined scheme.

Four primary methods of moving jobs in Multiple-Level Queues

  • Case 1: No Movement Between Queues
  • Case 2: Movement Between Queues
  • Case 3: Variable Time Quantum Per Queue
  • Case 4: Aging

Earliest Deadline First (EDF)

  • It is a dynamic priority and preemptive algorithm.
  • Addresses critical processing requirements of real-time systems: deadlines.
  • Job priorities are adjusted while moving through the system to process jobs in order most likely to allow each to run to completion before reaching their respective deadlines.
  • Initial job priority is inversely proportional to its absolute deadline.
  • Another scheme applied if jobs have the same deadline.
  • Priority may change as more important jobs enter the system.
  • Problems include missed deadlines, impossible throughput prediction, and high overhead.

Types of Interrupts

  • Page interrupt (memory manager): accommodate job requests.
  • Time quantum expiration interrupt
  • I/O interrupt: result from READ or WRITE command issuance.
  • Internal interrupt: triggered by result from arithmetic operation or job instruction.
  • Illegal arithmetic operation interrupt: dividing by zero; bad floating-point operation
  • Illegal job instruction interrupt: protected storage or non-existent access attempt, attempts to use an undefined operation code/ invalid data.

Interrupt Handlers

  • Control programs that handle the interruption event sequence.
  • When the OS detects a non-recoverable error, the interrupt handler follows its sequence.
    • Type of interrupt is described and stored to be passed on to the user as an error message.
    • State of the interrupt process is saved.
    • The interrupt is processed.
    • Processor resumes normal operation.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Process Management in Operating Systems Quiz
15 questions
Process vs Thread Overview
37 questions

Process vs Thread Overview

PromisedCharoite1423 avatar
PromisedCharoite1423
Operating Systems: Processes and Threads
42 questions
Use Quizgecko on...
Browser
Browser