Operating Systems: Fundamentals

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 role does the 'shell' play in facilitating user interaction with the kernel, and how has this interaction evolved from solely command-line interfaces to include graphical user interfaces?

The shell acts as an intermediary, translating user commands into instructions the kernel can understand. It has evolved from CLI to include GUI, broadening accessibility.

Explain how an operating system uses a 'mode bit' to differentiate between user mode and kernel mode, and why is this distinction crucial for system security and stability?

The 'mode bit' distinguishes between user (1) and kernel (0) modes. This distinction is crucial for security, preventing user-level programs from directly accessing sensitive system resources and thus maintaining system stability.

Describe the trade-offs between 'user convenience' and 'resource efficiency' as primary design goals in operating systems, specifically contrasting Windows and Linux OSs relative to these goals.

Windows prioritizes user convenience, potentially sacrificing some resource efficiency. Linux emphasizes efficiency, which might require more technical user management. The trade-off highlights different design philosophies targeting different user bases.

How does the concept of 'degree of multiprogramming' (DOM) influence CPU utilization, and what are the limitations or challenges associated with increasing DOM to maximize CPU usage?

<p>Increasing DOM generally raises CPU utilization by having more processes ready to run. Limitations include increased context switching overhead and potential resource contention or starvation.</p> Signup and view all the answers

Elaborate on the differences in scheduling mechanisms between preemptive and non-preemptive multitasking operating systems. Include a discussion of the advantages and disadvantages of each approach from the perspective of system responsiveness and fairness.

<p>Preemptive systems allow the OS to interrupt running processes, ensuring responsiveness and fairness. Non-preemptive systems rely on processes voluntarily yielding control, potentially leading to delays and starvation.</p> Signup and view all the answers

Describe how loosely coupled systems achieve inter-process communication and data sharing in multiprocessing operating systems. Contrast its approach with that of tightly coupled systems.

<p>Loosely coupled systems use message passing for communication and data sharing, while tightly coupled systems rely on shared memory. This difference impacts performance, complexity, and suitability for different multiprocessing architectures.</p> Signup and view all the answers

Compare and contrast the key characteristics and use cases of 'hard real-time operating systems' (RTOS) versus 'soft real-time operating systems', giving examples of applications where each type is most appropriate.

<p>Hard RTOSs guarantee strict deadlines, vital for critical systems like missile control. Soft RTOSs allow occasional deadline misses, suitable for streaming or banking, where some delay is tolerable.</p> Signup and view all the answers

Explain the concept of 'context switching' in operating systems, and discuss the key factors that influence the overhead associated with context switching, including hardware features and software optimizations.

<p>Context switching saves the state of a running process and loads the state of another. Overhead depends on factors like memory access speeds, CPU cache efficiency and OS optimization for state saving.</p> Signup and view all the answers

How do 'CPU-bound' and 'I/O-bound' processes differ in their demands on system resources, and how do operating system schedulers adapt to optimize performance for workloads with varying mixes of these process types?

<p>CPU-bound processes demand more CPU cycles, while I/O-bound processes require more I/O operations. Schedulers balance these demands, prioritizing I/O-bound processes to improve system responsiveness.</p> Signup and view all the answers

In the context of CPU scheduling algorithms, explain the 'convoy effect' and how does it specifically degrade the performance of First-Come, First-Served (FCFS) scheduling?

<p>The 'convoy effect' occurs when a long process blocks shorter process, causing them to wait. This seriously degrades FCFS performance.</p> Signup and view all the answers

What are the advantages and disadvantages of Shortest Job First (SJF) scheduling, and how does the concept of 'starvation' relate to the limitations of this algorithm?

<p>SJF minimizes average waiting time, promoting faster throughput, but can lead to starvation for longer processes if shorter jobs continuously arrive. This highlights a trade-off between efficiency and fairness.</p> Signup and view all the answers

Describe the key differences between Shortest Job First (SJF) and Shortest Remaining Time First (SRTF) scheduling algorithms. How does the preemptive nature of SRTF affect its performance and complexity compared to SJF?

<p>SJF is non-preemptive, running jobs to completion, while SRTF is preemptive, switching to shorter remaining time jobs. SRTF's preemptive nature adds complexity but can improve responsiveness to new short jobs.</p> Signup and view all the answers

Explain how 'aging' is used as a countermeasure against starvation and what are the potential challenges in implementing aging effectively?

<p>Aging increases the priority of waiting processes over time. Challenges include determining the appropriate aging rate and preventing excessive overhead from priority adjustments.</p> Signup and view all the answers

In Round Robin scheduling, how does the choice of the 'time quantum' affect system performance, and what are the trade-offs involved in selecting a very small versus a very large time quantum?

<p>Small time quantum values improve fairness but increase context switching, while large values reduce context switching but can degrade responsiveness. There must be a balance.</p> Signup and view all the answers

Contrast multilevel queue scheduling with multilevel feedback queue scheduling, focusing on how processes are assigned and migrated between queues in each approach, and the impact on overall system flexibility and responsiveness.

<p>Multilevel queue scheduling assigns processes permanently to queues, while multilevel feedback queue scheduling allows processes to migrate. This migration capacity increases flexibility and response of the overall system.</p> Signup and view all the answers

Discuss the significance of process synchronization in concurrent systems, detailing specific problems that can arise from unsynchronized access to shared resources and explain specific examples of these problems.

<p>Process synchronization is critical to prevent race conditions, data corruption, and inconsistencies when multiple processes access shared resources, and to maintain data integrity.</p> Signup and view all the answers

Explain the three essential requirements -- mutual exclusion, progress, and bounded waiting -- for a valid solution to the critical section problem. Describe a scenario where one of these conditions is violated, leading to system failure or inefficiency.

<p>Mutual exclusion prevents simultaneous access, progress ensures resource usage, and bounded waiting prevents starvation. Violating these leads to data corruption, deadlocks, or indefinitely postponed processes.</p> Signup and view all the answers

Compare and contrast binary and counting semaphores, detailing their respective use cases in addressing synchronization problems and how their underlying mechanisms differ.

<p>Binary semaphores manage single-resource access, ensuring mutual exclusion, while counting semaphores control access to multiple instances of a resource, managing availability.</p> Signup and view all the answers

Explain the complexities that arise in implementing producer-consumer problem with multiple producers and consumers, and how semaphores help maintain synchronization and avoid race conditions in its management?

<p>The complexities arise with coordinating and synchronizing concurrent access without creating collisions. Semaphores ensure only one producer or consumer accesses the buffer, preventing data corruption and managing resource availability.</p> Signup and view all the answers

Relate how the Dining Philosophers Problem models challenges in resource allocation and concurrency control, and describe common strategies or algorithms used to prevent deadlock in such systems.

<p>This models conflicts in resource allocation, leading to deadlock if philosophers simultaneously grab resources. Solutions use resource hierarchy or arbitration strategies.</p> Signup and view all the answers

Flashcards

Operating System (OS)

Acts as an interface between user applications and hardware and manages system resources.

User Convenience

How easily a user can interact with hardware. It's often secondary in Linux OS.

Efficiency in OS

How well an OS utilizes resources, often measured by the number of tasks executed per second (throughput). Primary goal for Linux OS.

Throughput

Refers to the number of tasks executed per second, indicating system efficiency.

Signup and view all the flashcards

Shell (in OS)

Outer layer interacting with users. Two types: GUI or CLI.

Signup and view all the flashcards

Kernel (in OS)

Core of the OS containing functions that define the actions of different modules.

Signup and view all the flashcards

System Call

A way for a user program to interact with the OS kernel.

Signup and view all the flashcards

User Mode

Execution mode where programs have limited access to system resources.

Signup and view all the flashcards

Kernel Mode

Execution mode where programs can access all resources.

Signup and view all the flashcards

Resource Management

Maps hardware resources to multiple applications, like CPU scheduling.

Signup and view all the flashcards

Process Management

How an OS runs multiple processes on system hardware (CPU scheduling).

Signup and view all the flashcards

Storage Management

How processes are stored in secondary memory (NTFS, FAT32).

Signup and view all the flashcards

Memory Management

OS manages memory, deciding which processes move in/out of RAM.

Signup and view all the flashcards

Security and Privacy (in OS)

Includes authentication, passwords, and prevents interference between programs.

Signup and view all the flashcards

Batch Processing OS

Operating system that doesn't interact with the computer directly; an operator groups similar tasks.

Signup and view all the flashcards

Multiprogramming OS

Multiple programs reside in RAM to increase CPU utilization.

Signup and view all the flashcards

Multitasking OS

Simply, a multiprogramming OS with Round-Robin Scheduling Algorithm. It can run multiple programs simultaneously.

Signup and view all the flashcards

Multiprocessing OS

An OS with more than one CPU in the system to do multiprocessing.

Signup and view all the flashcards

Real-Time OS

Handle tasks with very strict time limits with very small processing time. Response time is critical.

Signup and view all the flashcards

Distributed OS

Autonomous interconnected computers connected using a shared network.

Signup and view all the flashcards

Study Notes

  • These notes cover the fundamentals of operating systems, including their definition, goals, components, functions, types, and related concepts like process management and synchronization

What is an Operating System (OS)?

  • An OS is software that acts as an interface between user applications and hardware - CPU, Memory and I/O devices
  • It plays the role of a resource manager by simplifying application development and execution
  • It is a system program
  • Examples include Windows, Linux, and Mac OS
  • In short act like government

Goals of an OS

  • User Convenience: How easily a user can interact with hardware
  • Efficiency: How well the OS utilizes resources, evaluated in terms of throughput
  • Throughput indicates the number of tasks executed per second
  • User convenience is prioritized in Windows OS, while efficiency is secondary aim
  • Efficiency is the primary goal of Linux OS, with user convenience considered secondary

Parts of an OS

  • Consists of different modules (system programs)
  • Shell: Used to interact with the kernel, generally through GUI or CLI
  • Kernel: Consists of functions that define the functions of different modules of the OS.
  • Each OS has a different kernel
  • Some kernels have multiple shells; Windows and Linux support both GUI and CLI, while Linux generally support only CLI

System Call

  • The way a user program interacts with the OS
  • Involves a transition from Shell to Kernel.
  • Implemented using functions like open(), read(), write(), load(), execute(), abort(), fork(), and get pid()
  • This process involves two modes of operation: User Mode and Kernel Mode
  • A mode bit is used to define whether the OS is in User Mode (1) or Kernel Mode (0)
  • In kernel mode the executing program can access all resources

Functions of an OS

  • Resource Management: Mapping hardware resources to multiple applications simultaneously.
  • Process Management: How to run multiple processes on system hardware using CPU scheduling.
  • Storage Management: How processes are stored in secondary memory using a file system like NTFS or FAT32.
  • Memory Management: Storing processes and deciding which process to bring into RAM using multi-programming/tasking
  • Security and Privacy: Authentication methods like passwords, user, and admin modes prevent interference between programs
  • Accounting: Task manager

Types of OS

  • Batch Processing OS
  • Multiprogramming
  • Multitasking
  • Multiprocessing
  • Real Time OS
  • Embedded
  • Distributed OS
  • Typically consists of three components: CPU, Memory, and I/O.
  • Resides in main memory (RAM)

Batch Processing OS

  • This OS does not interact with the computer directly
  • An operator takes similar jobs, groups them into batches, and sorts the jobs of similar needs
  • Job completion time can be known and multiple users share the batch systems
  • The operators are well-versed with batch systems
  • Batch systems are hard to debug
  • Other jobs will have to wait for an unknown time if any job fails

Multiprogramming OS

  • Allows more than one program to reside in RAM to increase CPU Utilisation.
  • Increasing the Degree Of Multi-programming increases the CPU utilization.
  • Another process is scheduled to the CPU when a process leaves for I/O.
  • Only one process is processed by CPU at a time
  • Increases the throughput of the System and helps reduce the response time.
  • Lacks user interaction with the system resources.

Multitasking OS

  • A pre-emptive version of Multiprogramming and is a multiprogramming OS with a Round-Robin Scheduling Algorithm
  • Runs multiple programs simultaneously, and has improved user responsiveness
  • User interaction is one at a time

Multiprocessing OS

  • Multiple CPUs reside in the system, and provides enhanced throughput and robustness
  • Two types: tight coupled (shared memory) and loose coupled (each CPU using different memory)

Real Time OS

  • Serve real-time systems in a small time interval called response time
  • Used for systems that have strict time requirements, like missile systems, air traffic control systems, and robots.
  • Two types: Hard RTOS (strict response time e.g. missile, airbag systems) and Soft RTOS (deadline has slight flexibility e.g. banking, streaming)

Distributed Operating System

  • Autonomous interconnected computers communicate with each other using a shared communication network.
  • Have their own independent memory unit and CPU and are referred to as loosely coupled systems or distributed systems.
  • Provides high availability and robustness, scalable and load balanced
  • Main downfall is synchronization

Embedded OS

  • Designed for a specific purpose, is embedded in a machine to make them smart. E.g. Microwave, AC
  • User interaction is minimal and is rigid in nature, not easily reprogrammed once developed

Process Management

  • A program under execution. Initially, the program is stored in secondary memory.
  • For execution, it has to be brought in Main memory. Text (current activity), Data(information), Stack (local variables) and Heap (dynamic memory allocation)
  • Involves identifying the steps involved in completing a task, assessing the resources required for each step, and determining the best way to execute the task.

Process Attributes

  • Process Id: A unique identifier assigned to each process allowing for process State that can be ready or running
  • Program Counter
  • List of General-purpose Registers, Priority Info, List of files, and List of devices.
  • The attributes of a process are also known as the context of the process, and are stored in RAM
  • Every process has its own process control block(PCB), i.e. each process will have a unique PCB

Process State

  • New: A newly created process being created by an app downloaded from secondary memory
  • Ready: Ready for execution from main memory, and moves to the Ready state after being created
  • Run: Currently running process in CPU, only one process is in execution in a single processor from main memory; uses a dispatcher
  • Wait (or Block): Process requests an I/O access from main memory
  • Complete (or Terminated): Process completed its execution from main memory
  • Suspended Ready: Ready queue becomes full, some processes are moved to a suspended ready state
  • Suspended Block: Waiting queue becomes full
  • When any process changes its state, a context switching happens

Context Switching

  • Saving of one process's context and loading another process's context, with the dispatcher performing it
  • Loading and unloading the process from the running state to the ready state
  • Happens when:
  • High-priority process comes to a ready state
  • An interrupt occurs
  • User and kernel-mode switch occurs
  • Preemptive CPU scheduling is used

CPU-Bound vs I/O-Bound Processes

  • A CPU-bound process spends more time in the running state, and requires additional CPU Time
  • An I/O-bound process requires more I/O time, less CPU time, and spends more time in the waiting state
  • Process planning decides which process to run next to maximize CPU utilization, minimize execution time, and improve system response time.

Scheduling Queue

  • Job queue: Stores processes of the new state.
  • Ready queue: Stores processes of the ready state.
  • Device queue: Stores processes of the wait state.

Types of Schedulers

  • Long term scheduler (Job): Bring job from new to ready state.
  • Short term scheduler (CPU): Bring job from ready to running state.
  • Middle term scheduler: from ready to suspended state.

Objectives of Process Scheduling Algorithm

  • Maximum CPU Utilization and allocation should be fair
  • Maximum Throughput with minimum turnaround time and minimum waiting time
  • The process produces the first response as quickly as possible

Scheduling terminologies

  • Arrival Time: Time at which the process arrives in the ready queue
  • Completion Time: Time at which process completes its execution
  • Burst Time: Time required by a process for CPU execution
  • Turn Around Time: = Completion Time - Arrival Time
  • Waiting Time (WT) = Turn Around Time - Burst Time

Types of Scheduling

  • Preemptive Scheduling: Process switches from running state to ready state, or from waiting state to ready state
  • Non-Preemptive Scheduling: Process terminates or switches from running state to waiting state

Scheduling Algorithms

  • FCFS (First Come First Serve)

    • Scheduled based on arrival time, and tie prefer process with low process id
    • Non-pre-emptive
    • Draw Gantt chart to maintain the process order execution
    • First starts at 0
    • Problems include convoy effect and long waits
  • Shortest Job First (SJF)

  • Burst time or execution time based, in the instance of the tie arrival time and process ID is important

  • As SJF reduces the average waiting time, it is more efficient than FCFS.

  • One of the demerits of SJF is starvation

  • Not practically implemented as Burst time of process in advance is unknown.

  • Shortest Remaining Time First (SRTF)

  • SRTF

  • Burst time or execution time based, in the instance of the tie arrival time and process ID is important

  • Preemptive as the short process pre-empts any running process

  • One of the demerits of SJF is starvation

  • Priority Based Scheduling

  • Scheduled based on Priority. Mostly priority is unique for each process and question always give hint

  • Can be Pre-emptive and Non-preemptive. Either a higher or small number can be given as top priority depending on context

  • May face starvation

  • Round Robin

  • Criteria: Arrival time + time quantum.

  • time quantum is the maximum time for which a process is assigned the CPU, and after the duration the CPU is pre-empted from the process.

  • Preemptive, the process id with lower is always preferred

  • Fielding practices.

  • Multilevel Queuing Scheduling

  • Generally, one scheduling policy is allowed in a given computer system

  • For example, a common division is a foreground (interactive) process and a background (batch) process.

  • Fixed priority preemptive scheduling method - run all process of high priority and then serve low priority

  • Time slicing: Divide the whole CPU into fraction and serve them accordingly.

  • Multilevel Feedback Queuing Scheduling

  • CPU Scheduling, where a process can move between queues instead of multi-level queue scheduling

  • Priorities adjusted dynamically, multiple queues are present

  • Allows differing processes to move between different queues and prevents starvation by moving a process that waits too long up top a higher priority queue

Starvation and its Counter Measure

  • Starvation occurs when high priority processes keep executing, while low priority processes get blocked for indefinite time.
  • Even steady streams of higher-priority processes can cause starvation
  • This can be solved using Aging, which will gradually increase the long wait processes priority

Process Synchronization

  • The communication for each is needed between each other to achieve an objective
  • Involves processes being independent or cooperating, execution of process should not affect
  • Coordination of execution of multiple processes in a multi-process system to ensure that they access shared resources in a controlled and predictable manner.
  • Main objective is to ensure that various processes access shared resources without interference and to prevent the inconsistency of concurrent access data

Need of Synchronization

  • Requires between cooperating processes to obtain the expected result of execution
  • To prevent problems of inconsistency, data loss and deadlock.
  • Useful where Two process wants to communicate, for sharing common resources to store critical section resources
  • Share the shared variables

Race Condition

  • Potential of an executing process accessing the same code or sharing a variable to be incorrect
  • Process manipulations over data concurrently and depends on the outcome of the particular order which takes place.
  • Happens when threads of access in critical sections differ to the order in the thread
  • Require mutual exclusion, progress, and bound waiting

Solution using Lock

  • Allows for mutual exclusion and to prevent accessing the same data

Critical Section

  • Requires Mutual Exclusion – Process won't access same data, avoid race conditions
  • It make sure it doesn't prevent other data access and is in progress, if no current access
  • If the bound waits if the entry is trying to enter

Petersons Solution

  • Uses flags to store any intent process from entering critical section

Semaphore

  • Is a normal variable that helps achieving process synchronisation and used for mutual condition and race conditions as well as achieving synchronisation between processes or in access

  • Wait() or P() or Downgrade() and Signal() or V() or Upgrade()

  • Types include:

  • Binary Semaphore

  • Only have two values – 0 and 1, its value is initialized to value 1

  • It is used to implement the critical sections

  • Counting Semaphore

  • Its range can range from a unrestricted domain to control access to a resource

Classic Synchronization Problems

  • Bounded Buffer Producer/Consumer Problem

  • A buffer with a fixed size with producer can produce items and consumers pick items

  • Ensure, buffer is the critical section

  • Empty/Full conditions used

  • Reader Writer Problem

  • File shared between people to prevent editing same file or not being read or writers being blocked

  • Requires binary semaphore to restrict readers or writers and must restrict or is read count cannot interfere

  • Dining Philosophers Problem

  • K philosophers around a circle with limited amount of total K chopsticks

  • Philosopher is only allowed if they have two chopsticks and can pick up if there followers can pick up

  • Can lead to deadlock

Studying That Suits You

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

Quiz Team

Related Documents

More Like This

Operating Systems Quiz
5 questions

Operating Systems Quiz

StimulativeScholarship avatar
StimulativeScholarship
Overview of Operating Systems
10 questions
Operating System: Core Functions
10 questions

Operating System: Core Functions

AuthenticSerpentine5959 avatar
AuthenticSerpentine5959
Operating Systems: Definition and Core Functions
20 questions
Use Quizgecko on...
Browser
Browser