Operating System: Definition, Components & Multitasking

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

Which of the following best describes the role of an operating system?

  • It serves as a conceptual mediator between hardware and software applications. (correct)
  • It primarily focuses on managing network configurations.
  • It provides direct access to hardware resources for all applications.
  • It is responsible for compiling source code into executable programs.

What is the primary function of the resource allocator in an operating system?

  • To manage user accounts and permissions.
  • To optimize network traffic flow.
  • To resolve conflicting requests for resources in a fair and efficient manner. (correct)
  • To directly control hardware devices.

Which of the following is a key characteristic of multiprogramming?

  • Guaranteeing that each program receives an equal share of the CPU's time.
  • Managing the execution of multiple programs concurrently on a single CPU. (correct)
  • Focusing on minimizing the number of programs running at any given time.
  • Executing multiple processes truly simultaneously on separate CPUs.

What is the main goal of employing multiprogramming techniques in an operating system?

<p>To ensure that the CPU is never idle, thereby maximizing CPU utilization. (A)</p>
Signup and view all the answers

Which statement accurately describes the concept of multitasking?

<p>The concurrent execution of multiple processes by rapidly switching between them. (C)</p>
Signup and view all the answers

What is the typical duration of the time quantum used in multitasking operating systems?

<p>Typically less than 1 second. (C)</p>
Signup and view all the answers

Which of the following statements accurately distinguishes multiprogramming from multitasking?

<p>Multiprogramming maximizes CPU usage, while multitasking allows users to run multiple programs. (D)</p>
Signup and view all the answers

What is the primary purpose of spooling in an operating system?

<p>To use storage (disk/memory) as a buffer for slower I/O devices. (B)</p>
Signup and view all the answers

Which of the following correctly describes an interactive process?

<p>Requires input from the user and provides output to the user. (C)</p>
Signup and view all the answers

What information is typically stored within a Process Control Block (PCB)?

<p>Process state, program counter, and CPU registers. (B)</p>
Signup and view all the answers

Under which circumstances does process creation typically occur?

<p>During system initialization, upon execution of a process creation system call (e.g., fork), or by user request. (C)</p>
Signup and view all the answers

What is a key characteristic of context switching?

<p>It involves the CPU switching to another process when the current process is preempted or blocks. (D)</p>
Signup and view all the answers

What is an important consideration regarding context switching overhead?

<p>The CPU does no useful work during context switches. (A)</p>
Signup and view all the answers

Which of the following is a benefit associated with user-level threads (green threads)?

<p>Faster creation and switching with lower overhead compared to kernel-level threads. (B)</p>
Signup and view all the answers

Which of the following best describes the Shortest Job First (SJF) scheduling algorithm?

<p>It schedules the process with the shortest burst time next. (A)</p>
Signup and view all the answers

Which of the following algorithms can lead to starvation for longer jobs?

<p>Shortest Job First (SJF). (C)</p>
Signup and view all the answers

What is the key difference between Shortest Job First (SJF) and Shortest Remaining Time First (SRTF) scheduling algorithms?

<p>SJF is non-preemptive, while SRTF is preemptive. (D)</p>
Signup and view all the answers

An operating system uses the Round Robin (RR) scheduling algorithm with a time quantum of 5 milliseconds. If a process requires 23 milliseconds to complete, how many times will it be scheduled?

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

Which scheduling algorithm is most suitable for time-sharing systems?

<p>Round Robin (RR). (B)</p>
Signup and view all the answers

What is a potential disadvantage of using the Shortest Job First (SJF) scheduling algorithm?

<p>It can cause starvation for longer processes. (C)</p>
Signup and view all the answers

What is a race condition?

<p>A situation where multiple processes access shared data concurrently, and the outcome depends on the order of execution. (C)</p>
Signup and view all the answers

Which of the following is a necessary condition to ensure correctness in concurrent systems, particularly concerning shared resources?

<p>Mutual exclusion to prevent simultaneous access to critical sections. (B)</p>
Signup and view all the answers

Which of the following memory allocation strategies results in the smallest amount of leftover space, potentially leading to external fragmentation?

<p>Best Fit. (B)</p>
Signup and view all the answers

What is the primary goal of compaction in memory management?

<p>To reduce external fragmentation by moving processes to make memory contiguous. (B)</p>
Signup and view all the answers

How does Direct Memory Access (DMA) improve system performance?

<p>By enabling devices to transfer data directly to/from memory without CPU intervention, thus freeing the CPU for other tasks. (A)</p>
Signup and view all the answers

Flashcards

Operating System

A conceptual mediator between hardware and tasks, abstracting physical components and managing resource interactions.

Resource Allocator

Decides between conflicting resource requests to ensure efficient and fair usage.

Control Program

Manages program execution, prevents errors, and reduces I/O time through spooling or buffering; aka 'supervisor'.

Multiprogramming

Running multiple programs concurrently on a single CPU to maximize its utilization.

Signup and view all the flashcards

Multitasking

OS capability to execute multiple processes simultaneously, employing rapid time sharing.

Signup and view all the flashcards

Multiprogramming vs. Multitasking

Maximizing CPU usage versus running multiple programs concurrently

Signup and view all the flashcards

Spooling

Using storage (disk/memory) as a buffer to hold data for slower I/O devices.

Signup and view all the flashcards

Process

An instance of a program in execution. Can be batch, real-time, or interactive.

Signup and view all the flashcards

Process Control Block (PCB)

Stores process state, program counter, and CPU registers, containing pointer to page table and scheduling info.

Signup and view all the flashcards

Context Switching

When CPU switches to another process.

Signup and view all the flashcards

Threads

Lightweight processes that improve parallelism; can be user-level or kernel-level.

Signup and view all the flashcards

User-Level Threads

A thread library manages them in user space leading to faster creation. If one blocks, all block.

Signup and view all the flashcards

Kernel-Level Threads

Supported by the OS, allow for true concurrency, but with more overhead.

Signup and view all the flashcards

Scheduling

Determines which process gets the CPU next, based on criteria like utilization and response time.

Signup and view all the flashcards

FCFS (First-Come, First-Served)

A scheduling algorithm that is non-preemptive and simple, but can lead to poor turnaround times.

Signup and view all the flashcards

SJF (Shortest Job First)

A scheduling algorithm that minimizes average turnaround time, but can cause starvation for longer jobs.

Signup and view all the flashcards

SRTF (Shortest Remaining Time First)

Preemptive version of SJF. Dynamically updates remaining time as jobs run

Signup and view all the flashcards

Round Robin (RR)

Each process gets small, fixed time quantum in turn.

Signup and view all the flashcards

Priority Scheduling

Higher-priority processes run first.

Signup and view all the flashcards

SJF with aging priority

Adding wait time (aging) to give priority to low priority processes

Signup and view all the flashcards

Lottery Scheduling

Selects processes to assign resources based on a probabilistic drawing

Signup and view all the flashcards

Race Condition

Two or more processes access shared data concurrently, and the outcome depends on execution order.

Signup and view all the flashcards

TSL (Test-and-Set Lock)

Use hardware to set a lock atomically

Signup and view all the flashcards

Spooling

Use storage as a buffer to move to slower storage

Signup and view all the flashcards

Study Notes

  • Lecture support provided by StudCee, with special mentions to Mihai David & Boyan Karakostov, dated April 2, 2025

OS Definition

  • Conceptual mediator between hardware and tasks.
  • It abstracts physical components.
  • Provides structured space for processes to interact.
  • Main function includes managing process interactions, preventing hardware conflicts.

OS Components

  • Resource Allocator: Resolves conflicts between resource requests for efficiency and fairness.
  • Control Program: Also known as "supervisor."
    • Manages user program execution.
    • Prevents errors and misuse.
    • Reduces I/O time via spooling/buffering.

Multiprogramming

  • Allows concurrent execution of multiple programs on a single CPU.
  • Enhances CPU utilization by keeping it constantly busy.
  • Avoids CPU idling during I/O operations.

Multitasking

  • Enables the OS to execute multiple processes concurrently.
  • It allows users to perform multiple operations at once via time sharing.
  • Time quantum involved is typically less than 1 second.

Multiprogramming vs. Multitasking

  • Multiprogramming maximizes CPU usage.
  • Multitasking handles the execution of multiple programs.

Spooling

  • Leverages storage (disk/memory) as a buffer for slower I/O devices.
  • Example: Sending files to disk before printing.
  • Gives users the perception of dedicated access to resources.

Processes

  • A program in execution.
  • Types of processes:
    • Batch: Does not interact with users.
    • Real-time: Requires response from user/application.
    • Interactive: Requires user input and provides output.
  • Process Control Block (PCB):
    • Stores process state, program counter, CPU registers.
    • Contains pointer to page table and scheduling info.
  • Process Creation: Via System initialization, or A creation system call (e.g., fork), or User request (batch jobs), or spawned by another process
  • Process Termination: Can be voluntary (normal or error exit) or involuntary (fatal error or termination by another process).

Context Switching

  • CPU switches to another process when a process is preempted or blocks.
  • Steps Include:
    • Save current process state in its PCB.
    • Move PCB to appropriate queue.
    • Select next process and load that PCB.
    • Restore CPU context so execution can resume.
  • Overhead: CPU does no useful work during context switch.

Threads

  • Lighter weight than processes which improves parallelism.
  • User-Level Threads(Green Threads)
    • Managed by a thread library in user space.
    • Faster to create/switch.
    • Avoid kernel overhead.
    • If one thread blocks, all threads in the process block.
  • Kernel-Level Threads
    • Supported/managed directly by the OS.
    • True concurrency on multicore; if a single blocks others can run.
    • More overhead for creation and management.
  • Threading Models: Many-to-One, One-to-One, Many-to-Many.
  • Thread Pool: A pre-created list of threads to handle incoming tasks.

Scheduling Basics

  • Determines which process gets CPU next.
  • Criteria Includes CPU Utilization, Throughput, Turnaround Time, Waiting Time, Response Time.

Scheduling Algorithms

  • FCFS (First-Come, First-Served):
    • Non-preemptive.
    • Simple, but can lead to poor average turnaround time.
  • SJF (Shortest Job First):
    • Minimizes average turnaround time.
    • May cause starvation for longer jobs.
  • SRTF (Shortest Remaining Time First): Preemptive version of SJF, dynamically updates remaining time .
  • Round Robin (RR):
    • All processes get small, fixed time quantum in turn.
    • Good for time-sharing; easy to implement.
  • Priority Scheduling:
    • Higher-priority processes run first.
    • Aging can prevent low-priority process starvation.
    • SJF with aging priority = 1 / (execution time + 0.1 * wait time).
  • Lottery Scheduling:
    • Probabilistic selection of processes using tickets.
    • Random draws approximate proportional resource sharing.

Race Conditions & Mutual Exclusion

  • Race Condition: Multiple processes accessing shared data concurrently, where the outcome depends on execution order.
  • Requirements for Correctness in order to ensure mutual exclusion (Peterson’s / general):
    • Mutual exclusion: Ensure only one process is in critical section at a time.
    • No assumptions on CPU speed/number.
    • Progress: No process outside its critical section blocks others.
    • Bounded waiting: Ensure no process waits forever.

Synchronization Mechanisms

  • Peterson’s Algorithm: Classic software solution for two processes.
  • TSL (Test-and-Set Lock): Hardware instruction to set a lock atomically.
  • Semaphores:
    • wait() and signal() operations.
    • Can be binary (mutex) or counting.
  • Monitors:
    • High-level construct with condition variables.
    • Can allow Safer, more structured synchronization.
  • Message Passing: Processes communicate using send/receive.

Memory Management

  • Fragmentation: Can be internal (unused space within allocated block) or external (available memory is fragmented into unusable chunks).

Memory Management Overview

  • Address Binding: Can occur at compile time, load time, or run time
    • Types: Symbolic, relocatable, or absolute addresses.
  • Contiguous Allocation:
    • Each process gets one contiguous block.
    • Allocation strategies: First Fit, Best Fit, Worst Fit.
    • Is subject to Fragmentation issues.

Paging

  • Divides logical memory into pages and physical memory into frames.
  • A page table maps pages to frames.
  • Eliminates external fragmentation.
  • TLB (Translation Lookaside Buffer):
    • A cache for page-table lookups.
    • If there is no TLB hit, then to access page table in memory.

Virtual Memory and Page Replacement

  • Virtual Memory is managed through:
    • Demand paging: Pages are only loaded on demand.
    • Page fault triggers page load, with possible replacement.
  • Replacement Algorithms:
    • FIFO: Simple, potentially suffers from Belady's Anomaly.
    • LRU: Replaces page not used for the longest time.
    • Second Chance (Clock): Tracks usage bit, prefer unreferenced, unmodified.
  • Thrashing:
    • Constant paging and page-fault state.
    • Slows application-level processing;
    • Causes high paging activity and low CPU utilization, occuring when processes do not have enough frames.

Memory Allocation Algorithms

  • Intended for an OS to allocate memory blocks to processes, by:
    • Managing limited physical memory efficiently.
    • Reducing fragmentation (internal & external).
    • Common strategies for algos: First Fit, Best Fit, Worst Fit.
  • Best Fit:
    • Allocates smallest available which minimizes leftover space.
    • Can lead to many small, unusable gaps and requires searching the entire list of free blocks.
  • Worst Fit:
    • Allocates largest available block.
    • Leaves large leftover space , creates fewer, larger holes, requiring searching the whole list.
  • First Fit:
    • Allocates the first block that is big enough.
    • Faster than Best/Worst fit, may lead to scattered small holes at the beginning of memory, can have a good trade-off between speed and fragmentation.
  • Compaction: Reduces external fragmentation by moving processes to make memory contiguous and consolidate free memory; it can also be time-consuming.

Direct Memory Access (DMA)

  • Allows devices to directly transfer data to/from memory.
  • Frees CPU from data transfer operations, improves I/O performance, used for disk drives and graphics cards.

File and Directory Concepts

  • File: Abstract data type to create, write, read, delete, etc.
  • Directory Structure: Organizes files. Acyclic graph directories allow users to share files/folders.
  • Permissions: Owner/Group/Others (e.g., Unix style, octal), plus Locking: shared/exclusive, mandatory or advisory.

Allocation Methods

  • Contiguous Allocation:
    • All file blocks are stored in consecutive sectors on disk.
    • Provides simple, good performance, with possible External fragmentation, thus is hard to grow file
  • Linked Allocation:
    • Each block points to the next.
    • Easy to grow, random access is slow.
  • Indexed Allocation: An index block holds pointers to file blocks allowing Fast access but with extra overhead for index block.

File System Layout & Journaling

  • Boot Block:
    • Contains the bootloader.
  • Superblock:
    • Stores metadata about file system (size, block counts, etc.)
  • Journaling:
    • Write-ahead logging of metadata changes.
    • Fast recovery from crashes.
  • Examples: FAT32, NTFS, ext4, etc.

I/O (Input/Output)

  • Memory-Mapped I/O:
    • Device registers mapped into address space, and standard load/store instructions can access the hardware.
  • DMA (Direct Memory Access):
    • Offloads data transfer to a DMA controller, and Allows CPU to continue while transferring data.
  • Interrupts:
    • Device signals completion via interrupt, then context switch to ISR (Interrupt Service Routine), Precise vs. Imprecise interrupts

I/O Software Layers and Device Drivers

  • Layers:
    • User-Level I/O routines (e.g., read, write).
    • Device-Independent OS software (Naming, protection).
    • Device drivers (Knows device registers, commands.
    • Interrupt handlers for (Handle completion).
    • Buffering improves performance or reliability. May need page locking to prevent pages from being swapped.

Studying That Suits You

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

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser