Multi Programming

Tasks, Algorithms, Programs

  • Goal of Computer Systems: Execute tasks or jobs.

    • Terms "task" and "job" used synonymously; job may refer to a specific task instance.

    • Algorithm: A logical process allowing resolution of a problem in finite steps.

    • Program: An algorithm coded in a programming language, stored in secondary memory, and must be executed by CPU.

Processes

  • Definition: Central concept in OS; abstraction of an executing program.

  • Characteristics:

    • Active entity assigned to a processor.

    • Has a sequence of instructions, state, and assigned resources.

  • OS Management:

    • Creation and termination of processes.

    • Scheduling processes for execution.

    • Concurrency: policy for shared resource access.

Threads

  • Definition: Lightweight processes that execute instructions but do not own resources.

  • Processes manage internal parallelism via multi-threading—a topic for later discussion.

Motivation for Processes

  • The concept arose from the need for efficient CPU usage amidst evolving computer systems.

  • Processes can be paused by interrupts, affecting execution and resource management.

Computer System Evolution

Taxonomy

  • Standalone (1950-60): Resident monitor, batch operation.

  • Centralized (1960-70): Mainframes utilized with passive terminals, supporting remote job entry and time-sharing.

  • Decentralized (1970-): Emergence of mini-computers and computational autonomy.

  • Distributed (1980-): Independent nodes enabling multiprocessors and distributed databases.

Batch Processing

  • Batching jobs enhances resource usage.

    • Operators collect and execute batches for efficiency.

    • Requires algorithms for maximizing throughput.

  • Characteristics: Limited interaction between programs; management may be local or remote.

Time Sharing

  • Method allows multiple users to simultaneously control CPU through time slices.

    • Improves user response time.

    • May lead to inefficient resource use if users don’t require the CPU.

SPOOLING

  • Definition: Simultaneous Peripheral Operation On-Line.

  • Uses buffers to simulate I/O communication, minimizing waiting time for processes to access I/O devices.

Monoprogramming

  • Sequential program management with full resource allocation until process termination.

  • Aims to increase process throughput but limits CPU execution time.

Multiprogramming

  • Definition: Multiple independent programs loaded in memory simultaneously.

  • Enhances resource usage, but introduces complexities in process handling and protection.

Process Execution Example

Execution of Three Processes

  • Three processes A, B, and C demonstrate execution dynamics.

    • Process B requests I/O; execution time varies.

    • Interlaced execution improves resource use during I/O delays.

Interrupts

Mechanism

  • Definition: Interrupt halts normal fetch-execute cycles.

    • Essential for multiprogramming; CPU preemption is possible when interrupts occur.

Types of Interrupts

  • Hardware Interrupts: Asynchronous events from device controllers or timers.

  • Software Interrupts (Traps): Synchronous events caused by program execution errors or system calls.

Interrupt Management

  • Interrupts stop current process execution and redirect to an interrupt handler.

    • Process resumes from the point where interrupt occurred post-processing.

Management Details

  1. Interrupt request received by CPU.

  2. Execution of current instruction is completed.

  3. Check for interrupt signals and prepare control transfer.

  4. Select and assign interrupt handler; operations managed primarily by hardware.

Handling Multiple Interrupts

  • System must manage situations where multiple interrupts occur.

Strategies

  • Disable Interrupts: Simple, but no priority handling.

  • Nested Interrupts: Interrupts processed according to priority, enabling preemption of lower-priority interrupts.

Context Switching

  • The state of processes saved prior to an interrupt, utilizing a stack for state management.

Modern OS Characteristics

  • Interrupt-driven: OS kernel controls via interrupts or traps, determining active processes.

Execution Types

Sequential Execution

  • Programs executed in sequences—deterministic behavior with defined outputs.

Concurrent Execution

  • Multiple actions executed simultaneously; behavior is non-deterministic.

    • Critical for synchronizing processes in concurrent programming to prevent races.

Pseudo-parallelism

  • Limited processors create the illusion of parallel execution through rapid context switching.