Coconote
AI notes
AI voice & video notes
Try for free
Understanding Multitasking and Multiprogramming
Sep 29, 2024
Notes on Multitasking and Multiprogramming
Introduction
Operating systems (OS) enable running multiple programs simultaneously.
Single programs can't keep CPU busy all the time.
Users commonly want to run more than one program.
Multiprogramming
Definition
: Multiprogramming increases CPU utilization and user satisfaction by keeping programs organized so the CPU has tasks to execute.
Each program in execution is called a
process
.
OS keeps several processes in memory at the same time.
When a process needs to wait (e.g., for I/O operations), the OS switches to another process, ensuring the CPU remains busy.
Example
: A lawyer can manage multiple cases, working on different papers while waiting for one client’s trial.
Multitasking
Definition
: Multitasking allows the CPU to execute multiple processes by rapidly switching among them.
This provides fast response times to users.
Processes often execute for short durations before needing I/O, which may be interactive (e.g., keyboard/mouse input).
OS switches the CPU to another process while waiting for user input, maintaining CPU activity.
Memory Management
Several processes require efficient memory management, which will be discussed later.
The OS must choose which process runs next, a function known as
CPU scheduling
.
Virtual Memory
Definition
: Virtual memory allows processes larger than physical memory to execute.
It presents a large, uniform storage view to the user, abstracting physical memory limitations.
Essential for multiprogramming and multitasking systems to manage files and secure user operations.
Process Synchronization and Communication
Mechanisms must ensure processes do not get stuck in a
deadlock
.
OS protects itself and users by differentiating between user and kernel execution modes using a
mode bit
.
Modes of operation:
User Mode
: Executing user applications.
Kernel Mode
: Executing OS services.
Timer and CPU Control
Purpose
: Prevent user programs from getting stuck (e.g., infinite loops).
Timers can interrupt the CPU after a specified duration, allowing the OS to regain control.
Process Management
A
process
is an active entity, representing a program in execution.
The OS manages several activities related to processes:
Creating and deleting processes.
Scheduling processes on CPUs.
Synchronization and communication mechanisms.
File System Management
The OS provides a logical view of information storage, abstracting physical storage properties.
Files are collections of related information, and they can be organized into directories.
User permissions and access controls are crucial for file management.
Secondary and Tertiary Storage
Secondary storage (e.g., HDDs, SSDs) provides persistent storage for programs and data.
Tertiary storage is less critical but must still be managed by the OS.
Efficient management of secondary storage impacts overall system performance.
Caching
Concept
: Copying frequently accessed information into faster storage (cache) for quicker retrieval.
Caches help improve performance significantly, especially when managing multiple processes.
Cache coherence must be ensured in multi-core and distributed systems to maintain data consistency.
Protection Mechanisms
Protecting resources from unauthorized access is vital for system reliability.
Different user access levels can be managed through group functionality.
Virtualization
Abstracts hardware into multiple execution environments, creating the illusion of private computers.
Virtual machine managers (VMM) manage resources and provide isolation among VMs.
Virtualization is increasingly common in data centers for efficient resource management.
Summary
An OS manages hardware and provides an environment for application programs.
Interrupts facilitate hardware interaction with the OS.
Main memory is crucial for program execution, while non-volatile storage provides permanent data retention.
Modern OS utilize multiprogramming and multitasking to optimize CPU use and enhance user experience.
📄
Full transcript