1 of 168

Module I

Operating SystemsCourse Code: BCS303

Latharani T R

Assistant Professor

Dept. of Computer Science and Engineering

Jain Institute of Technology

Davangere.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

1

2 of 168

Course outcomes

  • CO1: Explain the structure and functionality of Operating system.
  • CO2: Apply appropriate CPU scheduling algorithms for the given problem.
  • CO3: Analyse the various techniques for process synchronization and deadlock handling.
  • CO4: Apply various techniques for memory management.
  • CO5: Explain file and secondary storage management strategies.
  • CO6: Describe the need for information storage mechanisms.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

2

3 of 168

Textbooks & Reference Books

1. Abraham Silberschatz, Peter Baer Galvin, Greg Gagne, Operating System Principles, 10th edition, Wiley-India, 2018

2. D.M Dhamdhere, Operating Systems: A Concept Based Approach, 3rd Ed, McGraw- Hill, 2013.

3. William Stallings, Operating Systems: Internals and Design Principles, 9th Edition, Pearson.

4. Andrew S.Tanenbaum, Modern operating Systems, fourth Edition, PHI Learning Pvt.Ltd., 2008

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

3

4 of 168

WHY STUDY OPERATING SYSTEMS

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

4

5 of 168

  • Almost all code runs on top of an operating system (OS).
  • Knowledge of how operating systems work is crucial to proper, efficient, effective, and secure programming.
  • Understanding
    • The fundamentals of operating systems,
    • How they drive computer hardware, and
    • What facilities they provide to the applications

is essential for both users and programmers of the OS.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

5

6 of 168

Definition of Operating Systems�

  • An operating system is software that manages a computer’s hardware.
  • Acts as an interface between a computer user and computer hardware.
  • They are capable of accomplishing these tasks in a wide variety of computing environments.
  • An operating system is called as a resource manager as it manages all the resources of a computer system efficiently like
    • CPU time,
    • Memory space,
    • Input/output devices,
    • Disk space,
    • Network bandwidth and
    • Other hardware resources.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

6

7 of 168

  • Performs all the basic tasks like
    • File management,
    • Memory management,
    • Process management,
    • Handling input and output, and
    • Controlling peripheral devices such as disk drives and printers.
  • Some popular Operating Systems include
    • UNIX
    • Linux,
    • Windows,
    • Android,
    • iOS,
    • Ubuntu etc.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

7

8 of 168

Operating systems are everywhere, from

  • Home appliances that include “Internet of Things” devices,
  • Smart phones,
  • Personal computers,
  • Enterprise computers,
  • Mainframe computers,
  • Cloud computing environments,
  • Automobiles,
  • TV,
  • Toys etc.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

8

9 of 168

Computer System Components

A computer system can be divided roughly into four components:

  • The hardware,
  • The operating system,
  • The application programs, and
  • A user.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

9

10 of 168

Abstract view of the components of a computer system

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

10

11 of 168

Two viewpoints of OS

  • User view

  • System View

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

11

12 of 168

User View

  • User's view of the computer varies based on the interface.
  • Different devices offer diverse user experiences.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

12

13 of 168

Traditional Computer Systems

  • PC and laptop setup with monitor, keyboard, and mouse.
  • Designed for single-user resource utilization.
  • Emphasis on ease of use over resource optimization.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

13

14 of 168

Shift to Mobile Devices

    • Increasing use of smartphones and tablets.
    • Connected through wireless technologies.
    • Touch screen interfaces replace traditional input methods.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

14

15 of 168

Mobile User Interface

  • Touch screen interactions (finger touch, press hold, swiping).
  • Voice recognition interfaces (e.g., Siri, Alexa).
  • Reflects the trend towards intuitive and user-friendly designs.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

15

16 of 168

Embedded Systems

  • Some computers lack a traditional user view.
  • Examples: home devices (washing machines, microwaves), automobiles etc.
  • Designed for autonomous operation with minimal user intervention.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

16

17 of 168

System View

  • The operating system plays a crucial role from the computer's perspective.
  • It serves as the interface between hardware and software.
  • Modern OS allows multiple programs to run simultaneously.
  • Manages the user programs’ execution.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

17

18 of 168

Resource Allocation

  • OS deeply involved with hardware.
  • Viewed as a resource allocator.
  • Allocates CPU time, memory space, storage, and I/O devices efficiently.
  • Ensures optimal utilization of available resources.
  • Balances efficiency and fairness in resource allocation in case of conflicting resource requests.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

18

19 of 168

Computer-System Organization

A modern general-purpose computer system consists of

1. one or more CPUs and

2. a number of device controllers connected through a common bus that provides access to shared memory

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

19

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

20 of 168

  • Each device controller is in charge of a specific type of device (for example, disk

drives, audio devices, and video displays).

The CPU and the device controllers can execute concurrently, competing for memory

cycles.

For a computer to start running—for instance, when it is powered up or rebooted—

  • The initial program, or bootstrap program, is executed when the system is powered on.
  • Bootstrap program is stored in read-only memory (ROM) or electrically erasable

programmable read-only memory (EEPROM).

  • The bootstrap program must load the operating system

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

20

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

21 of 168

  • Then the OS starts executing the first process such as init and waits for some event to occur.
  • When the CPU is interrupted, it stops what it is doing and immediately transfers execution to interrupt service routine (ISR).
  • The ISR executes; on completion, the CPU resumes the interrupted computation.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

21

22 of 168

Interrupt time line for a single process doing output.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

22

23 of 168

Storage Structure

  • Computer programs must be in main memory to be executed.
  • Main memory is the only large storage area that the processor can access directly.
  • Interaction is achieved through a sequence of load or store instructions to specific memory addresses.
  • The load instruction moves a word from main memory to an internal register within the CPU, whereas the store instruction moves the content of a register to main memory

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

23

24 of 168

  • We want the programs and data to reside in main memory permanently.
  • This arrangement usually is not possible for the following two reasons:
    • Main memory is too small to store all needed programs and data permanently.
    • Main memory is a volatile storage device
  • Most computer systems provide secondary storage as an extension of main memory.
  • The main requirement for secondary storage is that it be able to hold large quantities of data permanently.
  • The most common secondary-storage device is a magnetic disk, which provides

storage for both programs and data.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

24

25 of 168

  • The higher levels are expensive, but they are fast.
  • As we move down the hierarchy, the cost per bit decreases, whereas the access time increases.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

25

Storage-devices Hierarchy

26 of 168

  • Computer programs must be in main memory to be executed.
  • Main memory is the only large storage area that the processor can access directly.
  • Interaction is achieved through a sequence of load or store instructions to specific memory addresses.
  • The load instruction moves a word from main memory to an internal register within the CPU, whereas the store instruction moves the content of a register to main memory

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

26

27 of 168

I/O Structure

  • A computer system consists of CPUs and multiple device controllers that are connected through a common bus.
  • Each device controller is in charge of a specific type of device.
  • A device controller maintains some local buffer storage and a set of special-purpose

registers.

  • The device controller is responsible for moving the data between the peripheral devices that it controls and its local buffer storage.
  • Typically, operating systems have a device driver for each device controller.
  • This device driver understands the device controller and presents a uniform interface to the device to the rest of the operating system.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

27

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

28 of 168

To start an I/O operation,

1.The device driver loads the appropriate registers within the device controller.

2.The device controller, in turn, examines the contents of these registers to determine what action to take (such as "read a character from the keyboard").

3.The controller starts the transfer of data from the device to its local buffer.

4.Once the transfer of data is complete, the device controller informs the device driver via an interrupt that it has finished its operation.

5.The device driver then returns control to the operating system, possibly returning the data or a pointer to the data if the operation was a read.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

28

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

29 of 168

  • This form of interrupt-driven I/O is fine for moving small amounts of data but can produce high overhead when used for bulk data movement such as disk I/O.
  • To solve this problem, direct memory access (DMA) is used.
  • After setting up buffers, pointers, and counters for the I/O device, the device controller transfers an entire block of data directly to or from its own buffer storage to memory, with no intervention by the CPU.

29

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

30 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

30

Shows the interplay of all components of a computer system.

31 of 168

Computer-System Architecture

  • Single-Processor Systems
  • Multiprocessor Systems
  • Clustered Systems

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

31

32 of 168

Single-Processor Systems

    • Combine a main CPU with special-purpose processors to enhance performance and efficiency.
  • Main CPU:
    • Executes a general-purpose instruction set.
    • Handles both system and user processes.
    • Central unit for processing tasks.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

32

33 of 168

Special-Purpose Processors:

    • Dedicated to specific tasks (e.g., disk, keyboard, graphics controllers).
    • Examples:
      • Disk controllers manage disk operations and scheduling.
      • Keyboard processors convert keystrokes to signals.
    • Benefits:
      • Offload tasks from the CPU.
      • Improve overall system efficiency.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

33

34 of 168

Multiprocessor Systems

Key Advantages:

    • Increased Throughput: More processors result in faster task completion.
    • Economy of Scale: Sharing of peripherals, storage, and power supplies reduces costs.
    • Increased Reliability: Failure of one processor doesn't halt the system, just slows it down.

Graceful Degradation:

    • Ability to continue operation at a reduced level after a component failure.

Fault Tolerance:

    • Some systems go beyond and can operate seamlessly even after a single component failure.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

34

35 of 168

Types of Multiprocessing Systems

  • Asymmetric Multiprocessing (AMP):
    • Each processor is assigned a specific task.
    • Master-Slave Relationship:
      • Master processor controls the system.
      • Slave processors execute predefined tasks or await instructions.
    • Example: SunOS Version 4.
  • Symmetric Multiprocessing (SMP):
    • All processors are peers, with no master-slave relationship.
    • Each processor performs all tasks within the OS.
    • Typical SMP setups are balanced and efficient for multitasking.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

35

36 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

36

Symmetric multiprocessing architecture.

37 of 168

Modern Trends in Multiprocessing

  • Multi-Core Processors:
    • Definition: Multiple compute cores on a single chip, essentially a multiprocessor on one chip.
    • Examples:
      • Dual-Core Design: Two cores on the same chip, each with its own registers and cache.
      • N-Way Chips: More cores on a chip, becoming common in high-end systems.
  • Core Design Variations:
    • Local Cache: Each core has its own cache.
    • Shared Cache: Cores share a cache.
    • Combination: Mix of local and shared caches.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

37

38 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

38

A dual-core design with two cores placed on the same chip

39 of 168

Clustered Systems

    • Consist of multiple CPUs gathered together to perform computational tasks.
    • Composed of two or more individual systems connected via a Local-Area Network (LAN) or high-speed interconnects like InfiniBand.
  • Key Advantage:
    • High Availability: Service continues even if one or more systems in the cluster fail, achieved through redundancy.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

39

40 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

40

General structure of a clustered system

41 of 168

How Clustered Systems Work

  • Cluster Software Layer:
    • Runs on all nodes within the cluster.
    • Monitoring:
      • Each node monitors others via the network.
      • If a node fails, another node takes over its storage and restarts its applications.
  • Types of Clustering:
    • Asymmetric Clustering:
      • One machine is in hot-standby mode, monitoring the active server.
      • If the active server fails, the standby machine takes over.
    • Symmetric Clustering:
      • Multiple machines run applications and monitor each other.
      • More efficient as it utilizes all available hardware.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

41

42 of 168

Types of Operating Systems

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

42

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

43 of 168

Batch Systems

  • Designed for sequential job management.
  • Jobs processed in bulk with predetermined input.
  • Minimal operator intervention during processing.
  • Ideal for handling large volumes of similar jobs with common requirements efficiently.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

43

44 of 168

Batch Processing Operating Systems

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

44

45 of 168

    • Results in speed enhancement.
  • Key benefit: Can handle multiple users simultaneously.
  • Suitable for large projects with numerous tasks.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

45

46 of 168

  • Widely used in business and scientific applications.
  • Maximizing resource utilization (CPU time, memory, storage).
  • Efficient scheduling and processing of jobs in batches.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

46

47 of 168

Multiprogrammed Systems

  • Ability to run multiple programs is crucial for optimal system performance.
  • Users want to run more than one program simultaneously.
  • Single programs may not keep CPU or I/O devices consistently busy.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

47

48 of 168

Multiprogramming for CPU Utilization

  • Modern OS employs multiprogramming for CPU utilization.
  • Allows several jobs in memory simultaneously.
  • CPU always has a job to execute, eliminating idle time.
  • Multiprogramming increases CPU utilization.
  • CPU scheduling ensures efficient process execution.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

48

49 of 168

  • Processes may wait for tasks like I/O operations to complete.

  • CPU switches to another process during waiting periods.

Memory layout for a multiprogramming system

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

49

50 of 168

Multitasking Systems

  • It is a logical extension of multiprogramming.
  • In multitasking systems, the CPU executes multiple processes by switching among them,
  • Switches occur frequently, providing the user with a fast response time.
  • CPU switches to another process during waiting periods.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

50

51 of 168

Time-Sharing Systems

  • Logical extension of multiprogramming for fair user resource access.
  • More complex than multiprogramming.
  • Enables multiple users to access computer resources concurrently.
  • Ensures fair and impartial resource allocation.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

51

52 of 168

  • Users get CPU attention in time slices, slots, or quantum.
  • Typically 10 to 100 milliseconds duration.
  • Primary goal: Provide each user with the illusion of sole control.
  • Multiple jobs kept in memory simultaneously.
  • Requires advanced mechanisms for fair user access.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

52

53 of 168

Time-Sharing Systems

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

53

54 of 168

Real-Time Systems (RTS)

  • RTS prioritize meeting of specific timing constraints or deadlines.
  • Unlike traditional systems, emphasis on delivering results within a specified time frame.
  • Widely used in critical applications where timely responses are crucial.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

54

55 of 168

Real-Time Systems

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

55

56 of 168

Two main types:

  • Hard Real-Time Systems
  • Soft Real-Time Systems

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

56

57 of 168

Hard Real-Time Systems

  • Deadline adherence is critical.
  • Used in safety-critical applications like medical devices and aerospace systems.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

57

58 of 168

Soft Real-Time Systems

  • Timing constraints exist, but occasional deadline misses are acceptable.
  • Found in applications like multimedia, video streaming, and online gaming.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

58

59 of 168

Application Areas

  • Embedded systems commonly run real-time operating systems.
    • Scientific experiments,
    • medical imaging,
    • industrial control, and
    • display systems.
    • Specific applications in automobile-engine fuel injection,
    • home appliances, and
    • weapon systems.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

59

60 of 168

Operating System Operations

Dual-Mode Operation

  • Purpose:
    • To distinguish between the execution of operating-system code and user-defined code.
  • Modes of Operation:
    • User Mode
    • Kernel Mode (also known as Supervisor Mode, System Mode, or Privileged Mode)

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

60

61 of 168

Mode Bit:

  • A hardware bit added to indicate the current mode:
    • Kernel Mode (0)
    • User Mode (1)
  • When executing user applications, the system is in User Mode.
  • When a system call is made, the system switches to Kernel Mode.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

61

62 of 168

  • System Operations and Transitions
  • System Boot:
    • Hardware starts in Kernel Mode.
    • The operating system is loaded, and user applications start in User Mode.
  • System calls Interrupts and Traps:
    • Cause the system to switch from User Mode to Kernel Mode.
    • Operating system takes control in Kernel Mode.
    • System switches back to User Mode when control is passed to a user program.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

62

63 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

63

Transition from user to kernel mode

64 of 168

  • Protection Purpose:
    • To protect the operating system from errant users and users from one another.
  • Privileged Instructions:
    • Certain machine instructions that may cause harm are designated as privileged.
    • These can only be executed in Kernel Mode.
  • Illegal Instructions:
    • If a privileged instruction is attempted in User Mode, it is trapped by the hardware and treated as illegal.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

64

65 of 168

Timer

  • Prevent user programs from getting stuck, running indefinitely without returning control to the operating system.
  • A timer is set to interrupt the system after a specified period.
  • Period can be fixed or variable.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

65

66 of 168

Variable Timer Implementation:

    • Fixed-Rate Clock ticks consistently.
    • Counter decrements with each tick.
    • When counter reaches 0, an interrupt occurs.

Operating System Role:

    • OS sets the timer before handing control to the user program.
    • Timer ensures the program does not exceed allowed runtime.
    • If the counter reaches zero or negative, the OS terminates the program.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

66

67 of 168

Process Management

    • A process is a program in execution.
    • Resources Required:
      • CPU time, memory, files, and I/O devices.
    • Process Lifecycle:
      • When a process terminates, the OS reclaims any reusable resources.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

67

68 of 168

Program:

    • A passive entity, such as a file stored on disk.

Process:

    • An active entity in execution.

Single-Threaded Process:

    • One program counter specifying the next instruction to execute.

Multithreaded Process:

    • Multiple program counters, each pointing to the next instruction.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

68

69 of 168

  • OS Responsibilities in Process Management
    • Creating and Deleting Processes:
      • Manages both user and system processes.
    • Suspending and Resuming Processes:
      • Temporarily halts and restarts processes.
    • Process Synchronization:
      • Ensures proper execution sequence among processes.
    • Process Communication:
      • Facilitates inter-process communication.
    • Deadlock Handling:
      • Manages situations where processes are stuck waiting for each other.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

69

70 of 168

Memory Management

  • Main Memory is a large array of words or bytes that serves as a repository for quickly accessible data.
    • Shared by: CPU and I/O devices.
  • Memory Access:
    • Instruction-Fetch Cycle: CPU reads instructions from memory.
    • Data-Fetch Cycle: CPU reads and writes data to memory.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

70

71 of 168

Importance of Memory Management

  • Direct Access:
    • Main memory is typically the only large storage device that the CPU can directly address and access.
  • Need for Memory Management:
    • To improve CPU utilization and system responsiveness, multiple programs must be kept in memory.
    • This necessitates effective memory management by the operating system.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

71

72 of 168

  • OS Responsibilities in Memory Management
    • Tracking Memory Usage:
      • Monitoring which parts of memory are in use and by whom.
    • Deciding Memory Allocation:
      • Determining which processes and data to move in and out of memory.
    • Allocating and De-allocating Memory:
      • Dynamically allocating and freeing memory space as needed.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

72

73 of 168

Storage Management

1. File-System Management

2. Mass-Storage Management

3. Caching

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

73

74 of 168

File-System Management

  • File - collection of related information defined by its creator.
  • They represent programs (both source and object forms) and data.
  • Data files maybe numeric, alphabetic, alphanumeric, or binary.
  • Normally organized into directories to make them easier to use.
  • When multiple users have access to files, it's important to manage who can access them and define the specific actions they can perform, such as reading, writing, or appending data.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

74

75 of 168

OS Responsibilities in File Management

1. Creating and deleting files

2. Creating and deleting directories to organize files

3. Supporting primitives for manipulating files and directories

4. Mapping files onto secondary storage

5. Backing up files on stable (nonvolatile) storage media

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

75

76 of 168

  • Mass-Storage Management
    • Programs are stored on a disk until loaded into memory.
    • Disks serve as both the source and destination for processing data.
  • OS Responsibilities:
    • Efficient management is crucial for overall system performance.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

76

77 of 168

Key Activities in Disk Management

  • Free-Space Management:
    • Keeping track of available storage space.
  • Storage Allocation:
    • Determining how disk space is allocated to files and programs.
  • Disk Scheduling:
    • Optimizing the order in which disk operations are performed for efficiency.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

77

78 of 168

Secondary Storage:

  • Frequently used for active processing; needs to be fast and efficient.

Tertiary Storage:

  • Slower, used for backups, seldom-accessed data, and long-term archival.
  • Examples: Magnetic tape drives, CDs, DVDs.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

78

79 of 168

Caching

    • Caching is the process of storing copies of data in a faster storage system (the cache) temporarily.
    • Purpose: To speed up data access by checking the cache before fetching from the main storage.
  • Process:
    • Check if the data is in the cache.
    • If present, use the cached data.
    • If not, fetch from the source, cache it, and then use it.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

79

80 of 168

Importance of Caching

  • Performance Boost:
    • Without caching, the CPU would need to wait several cycles for data from main memory, slowing down processing.
  • Storage Hierarchy:
    • Main Memory as Cache: Main memory acts as a fast cache for secondary storage, bridging the speed gap between the CPU and slower storage systems.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

80

81 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

81

82 of 168

Caching Example & Data Propagation

  • Increment Operation Example:
    • I/O Operation: Copy the disk block containing data A to main memory.
    • Copying A: Transfer A from main memory to the cache and an internal register.
    • Data Distribution: A exists on the magnetic disk, in main memory, in the cache, and in an internal register.
    • Inconsistency Post-Operation: After incrementing A in the internal register, A's value differs across storage systems.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

82

83 of 168

Migration of integer A from disk to register

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

83

84 of 168

I/O Systems

  • The I/O subsystem consists of several components:

1. A memory-management component that includes buffering, caching, and spooling

2. A general device-driver interface

3. Drivers for specific hardware devices.

  • Only the device driver knows the peculiarities of the specific device to which it is assigned

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

84

85 of 168

Protection and Security

  • Mechanism for controlling the access of processes or users to system resources.
  • Defense against internal and external attacks on the system.

Purpose of Protection:

  • Access Control: Ensures that only authorized users or processes can access certain resources.
  • Error Detection: Improves system reliability by detecting latent errors at the interfaces between subsystems.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

85

86 of 168

  1. Viruses and Worms: Malicious software that can harm the system.
  2. Denial of Service (DOS): Overwhelming the system to make it unavailable.
  3. Identity Theft: Stealing personal information to impersonate someone.

User Authentication:

  • Systems maintain user names and IDs for distinguishing users.
  • During login, the system assigns the appropriate user ID, which is linked to all processes and threads initiated by that user.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

86

87 of 168

Distributed Systems

  • Collection of physically separate, heterogeneous computer systems that are networked to provide the users with access to the various system resources
  • Access to a shared resource increases
    • Computation speed
    • Functionality
    • Data availability and
    • Reliability

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

87

88 of 168

  • A network is a communication path between two or more systems.
    • Networks vary by the
    • Protocols used
    • Distances between nodes and
    • Transport media.
  • Common network protocol are
    • TCP/IP (Transmission Control Protocol/Internet Protocol )
    • ATM (Asynchronous Transfer Mode)

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

88

89 of 168

  • Networks are characterized based on the distances between their nodes.
    • A local-area network (LAN) connects computers within a building.
    • A wide-area network (WAN) usually links buildings, cities, or countries.
    • A metropolitan-area network (MAN) could link buildings within a city.
  • The media to carry networks are
    • Copper wires,
    • Fiber strands, and
    • Wireless transmissions

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

89

90 of 168

Special-Purpose Systems

1. Real-Time Embedded Systems

2. Multimedia Systems

3. Handheld Systems

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

90

91 of 168

  • Real-Time Embedded Systems
    • Found in devices like car engines, manufacturing robots, VCRs, and microwave ovens.
    • Designed for dedicated tasks with limited, focused functions.
  • System Characteristics:
    • Operate on simple hardware with minimalistic operating systems.
    • Primarily focused on monitoring and managing hardware, like automobile engines and robotic arms.
  • Real-Time Operating Systems (RTOS):
    • Systems with rigid time constraints for processing.
    • Tasks must be completed within set time limits to avoid system failure.
    • Embedded systems often rely on RTOS to meet precise timing requirements.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

91

92 of 168

Multimedia Systems

  • Multimedia data consist of audio and video files as well as conventional files.
  • Multimedia data must be delivered(streamed) according to certain time restrictions.
  • Multimedia describes a wide range of applications. These include

1. Audio files such as MP3

2. DVD movies

3. Video conferencing

4. Live webcasts of speeches

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

92

93 of 168

Handheld Systems

  • Handheld systems include
    • PDAs and
    • Cellular telephones.
  • Main challenge - Limited size of devices.
  • Because of small size, most handheld devices have a
    • Small amount of memory,
    • Slow processors, and
    • Small display screens.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

93

94 of 168

Computing Environments

1. Traditional Computing

2. Client-Server Computing

3. Peer-to-Peer Computing

4. Web-Based Computing

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

94

95 of 168

Traditional Computing

  • Office Environment:
    • PCs and Networks: Personal computers connected via a network with servers providing file and print services.
  • Home Networks:
    • Single Computer Setup: Typically, a single computer connected through a slow modem.
    • Security Measures: Some homes employ firewalls to protect against security breaches.
  • Expansion with Web Technologies:
    • Portals: Companies use web portals for access to internal servers.
    • Network Computers: Devices focused on web computing.
    • Handheld PDAs: Connect to wireless networks for accessing company portals.
  • System Types:
    • Batch Systems: Processed jobs in bulk with predetermined input.
    • Interactive Systems: Wait for user input to process.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

95

96 of 168

Client-Server Computing

  • Server Categories:
    • 1) Compute Servers:
      • Provides an interface for clients to request actions (e.g., read data).
      • Server executes the requested action and returns results to the client.
    • 2) File Servers:
      • Offers a file-system interface for clients.
      • Clients can create, read, and delete files.
      • Example: A web server that delivers files to clients using web browsers.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

96

97 of 168

Peer-to-Peer Computing

    • All nodes are considered peers
    • Each can act as both a client and a server.
    • Advantage:
    • Unlike client-server systems, where the server can be a bottleneck, peer-to-peer systems distribute services across multiple nodes.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

97

98 of 168

    • Joining the Network:
    • A node must join the peer network to participate.
    • Service Discovery Methods:
      • Centralized Lookup:
        • Node registers its service with a centralized lookup service.
        • Other nodes contact this service to find out which node provides the desired service.
      • Broadcast Request:
        • A peer broadcasts a service request to all other nodes.
        • Nodes providing the service respond to the request.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

98

99 of 168

Web-Based Computing

  • This includes
    • PC
    • Handheld PDA &
    • Cell phones
  • Load balancer is a new category of devices to manage web traffic among similar servers.
  • In load balancing, network connection is distributed among a pool of similar servers.
  • Use of operating systems like Windows 95, client-side, have evolved into Linux and Windows XP, which can be clients and servers

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

99

100 of 168

Operating System Services

  • OS makes certain services available to users and their programs.
  • These services make the programming task easier for the programmer.
  • The services provided may differ from one system to another, but we can identify common classes.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

100

101 of 168

A view of operating system services

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

101

102 of 168

User interfaces

  • Graphical User Interface (GUI)
  • Touch-screen interface.
  • Command-Line Interface (CLI)

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

102

103 of 168

Graphical User Interface (GUI)

  • Most common UI.
  • Window system with a mouse as a pointing device.
  • Users interact through menus, make selections, and input text via a keyboard.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

103

104 of 168

Touch-screen interface

  • Phones and tablets utilize a touch-screen interface.
  • Users interact by sliding fingers across the screen or pressing on-screen buttons.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

104

105 of 168

Command-Line Interface (CLI)

  • Alternative to GUI.
  • Relies on text commands.
  • Users input commands through a keyboard in a specific format with options.
  • Some systems offer a combination of GUI, touch-screen, and CLI options.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

105

106 of 168

Program execution

  • The OS facilitates the loading of a program into memory and its execution.
  • The program must be able to end its execution, either normally or abnormally (indicating error).

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

106

107 of 168

I/O operations

  • A running program may need input/output(I/O) from a file or an I/O device, for the functions such as reading from a network interface or writing to a file system.
  • Users cannot directly control I/O devices for reasons of efficiency and security.
  • Therefore, the operating system must provide a means to do I/O.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

107

108 of 168

File-system manipulation

  • Programs interact with files and directories using various operations.
  • Common operations include
    • Reading,
    • Writing,
    • Creating,
    • Deleting by name,
    • Searching for specific files,
    • Setting access permissions, and
    • Obtaining file information.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

108

109 of 168

  • Many operating systems offer a variety of file systems.
  • Each file system may provide unique functionality or performance characteristics.

E.g

  • Windows – FAT, NTFS, HPFS
  • UNIX - EXT, MINIX

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

109

110 of 168

Communications

  • Information sharing may be necessary between processes running on the same machine or on separate computers connected by a network.
  • Communications may be implemented via
    • Shared memory, in which two or more processes read and write to a shared section of memory, or
    • Message passing, in which packets of information in predefined formats are moved between processes by the operating system.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

110

111 of 168

Error detection

  • Operating systems must continuously detect and address errors to ensure system reliability.
  • Errors may originate in various components:
    • CPU and memory hardware (e.g., memory errors, power failures).
    • I/O devices (e.g., network connection failures, printer paper shortage).
    • User programs (e.g., arithmetic overflow, illegal memory access).

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

111

112 of 168

    • The operating system must take the correct action for each type of error.
    • Actions ensure correct and consistent computing.
    • System Halting
      • In critical situations, the operating system may have to halt the system.
      • Halt is a last resort to prevent further damage or data corruption.

2. Process Termination

      • In certain scenarios, the OS might terminate a process causing errors.
      • Prevents the propagation of errors and maintains system stability.

3. Error Codes

      • OS may return error codes to processes for self-detection and correction.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

112

113 of 168

Resource allocation

  • When there are multiple processes running at the same time, resources must be allocated to each of them.
  • The operating system manages many different types of resources such as
    • CPU cycles,
    • Main memory,
    • I/O devices and
    • File storage.
  • Operating systems use scheduling and allocation algorithms to allocate these resources.
  • There may also be routines to allocate printers, USB storage drives, and other peripheral devices.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

113

114 of 168

Logging

  • Logging is helpful to keep track of which programs consume what kinds and quantities of computer resources.
  • Record keeping can either be done just
    • To collect consumption statistics, or
    • For accounting purposes (so users can receive bills).
  • Helpful for system administrators to change the configuration of the system to improve computing services.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

114

115 of 168

In multiuser or networked systems, owners strive for control over data to prevent

    • Unauthorized access and
    • Interference among concurrent processes.
  • Implementation of user authentication through passwords ensures that only authorized users can access and interact with sensitive information.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

115

116 of 168

  • Protection extends to external devices, including network adapters.
  • Encryption, firewalls, and secure protocols contribute to network security.
  • Regular patching of vulnerabilities at all system tiers is essential.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

116

117 of 168

System calls

  • Way for programs to interact with the operating system.
  • A computer program makes a system call when it makes a service request to the operating system’s kernel.
  • System call provides the services of the operating system to the user programs via Application Program Interface (API).
  • The API specifies a set of functions that are available to an application programmer.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

117

118 of 168

  • A programmer accesses an API via a library of code provided by the operating system.
  • In the case of UNIX and Linux for programs written in the C language, the library is called libc.
  • System calls are the exclusive entry points into the kernel system.
  • They provide a standardized way for programs to access system resources.
  • A system call can be written in high-level languages like C, C++, Pascal or in assembly language.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

118

119 of 168

  • To illustrate how system calls are used, let us take a UNIX command

cp in.txt out.txt

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

119

120 of 168

The handling of a user application by invoking the open () system call

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

120

121 of 168

  • Types of System Calls
    • Process Control: e.g. fork, exec, exit, wait
    • File Management: e.g. open, read, write, close
    • Device Management: e.g. ioctl, read, write
    • Information Maintenance: e.g. getpid, time, uname
    • Communication: e.g. create, socket, send, receive

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

121

122 of 168

Key System Calls:

  • end, abort – Halt program execution (normal/abnormal termination)
  • load, execute – Load and run a new program
  • create process, terminate process – Start or stop a process
  • get/set process attributes – Manage process details (e.g., priority)
  • wait for time – Delay execution for a set time
  • wait event, signal event – Wait for or signal events
  • allocate and free memory - Manage memory allocation.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

122

123 of 168

Process Execution Flow

  • Program Halting:
    • Execution can halt normally (end) or abnormally (abort).
    • In case of failure, error messages are dumped for debugging.
  • Control Flow After Program Execution (Two options):
    1. Return Control to the Invoking Program:
      • Saves the memory image of the existing program.
      • Allows the existing program to resume after the loaded program terminates.
    2. Concurrent Execution:
      • If both programs continue concurrently, a new process is created (multiprogramming).

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

123

124 of 168

Process Monitoring & Event Management

  • Process Attribute Control:
    • Modify job priorities or maximum execution times.
  • Process Termination:
    • Terminate if incorrect or no longer needed.
  • Waiting for Events:
    • Pause execution until an event occurs; signal when completed

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

124

125 of 168

File Management System calls

  • create file, delete file
  • open, close
  • read, write, reposition
  • get file attributes, set file attributes

Working procedure:

1) create and delete files.

2) Once the file is created,

    • open it to use it.
    • may also read or write.

3) close the file.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

125

126 of 168

We need to be able to

    • Determine the values of file-attributes and
    • Reset the file-attributes if necessary.
  • File attributes include
    • File name
    • File type
    • Protection codes and
    • Accounting information.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

126

127 of 168

Device Management System calls

    • Request device, release device;
    • Read, write, reposition;
    • Get device attributes, set device attributes;
    • Logically attach or detach devices.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

127

128 of 168

Resource Allocation & Device Usage

  • Additional Resources Needed for Program Execution:
    • Examples include memory, tape drives, or files.
    • Resources must be requested and allocated to the program.
  • Resource Availability:
    • If available, control is returned to the user program.
    • If unavailable, the program waits until released.
  • Files as Virtual Devices:
    • System calls for files also apply to devices due to their similarity.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

128

129 of 168

Information Maintenance System calls

  • get time or date, set time or date
  • get system data, set system data
  • get process, file, or device attributes
  • set process, file, or device attributes

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

129

130 of 168

  • Most systems have a system call to return
    • current time and
    • current date.
  • Other system calls may return information about the system, such as
    • number of current users
    • version number of the OS
    • amount of free memory or disk space.
  • The OS keeps information about all its processes, and there are system calls to access this information.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

130

131 of 168

Communication System calls

  • create, delete communication connection
  • send, receive messages
  • transfer status information
  • attach or detach remote devices

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

131

132 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

132

Two models of communication.

1) Message-passing model and

2) Shared Memory Model

133 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

133

Message Passing Model

    • Open Connection:
      • Use the open connection system-call.
    • Identifiers:
      • get hostid and get processid system-calls translate host/process names into identifiers.
    • Permission:
      • Recipient process gives permission with accept connection system-call.
      • Receiving processes, called daemon processes, wait for connections using wait for connection.

134 of 168

Message Exchange:

    • read message and write message system-calls are used to send and receive messages.

Close Connection:

    • The communication is terminated with the close connection system-call.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

134

135 of 168

Advantages of Message Passing:

      • Ideal for transferring smaller amounts of data between processes.
      • Simpler than shared memory in terms of design and implementation.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

135

136 of 168

Shared Memory Model

    • Processes access shared memory using the map memory system-call.
    • Data exchange is done by reading and writing to the shared memory region.

Process Responsibility:

    • Processes manage their access and must ensure no simultaneous writes to the same location.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

136

137 of 168

  • Advantages of Shared Memory:
    • Offers faster communication than message passing.
  • Disadvantages:
    • Processes are responsible for managing memory access and preventing conflicts.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

137

138 of 168

System Programs

  • Integral software designed to administer and regulate computer system functionality at a system level.
  • Close interaction with the operating system.
  • Core responsibility: manage and control computer hardware and resources(memory, processors, and various devices.)
  • Provide user-friendly interface and for enhanced user experience and development and execution.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

138

139 of 168

System programs in the operating system hierarchy

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

139

140 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

140

Six Categories of System Programs

  1. File Management:
    • Programs that create, delete, copy, rename, print, and manipulate files or directories.
    • Examples: File Explorer, command-line utilities like cp, mv, rm.
  2. Status Information:
    • Programs that query the system for information like date, time, available memory, disk space, or performance statistics.
    • Examples: top, df, date, system logs, performance monitors.

141 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

141

3. File Modification:

  • Text editors for creating or modifying files, search tools, and text processing commands.
  • Examples: vim, nano, grep sed

4. Programming-Language Support:

  • Compilers, assemblers, debuggers, and interpreters for languages like C, C++, Java, Python, etc.
  • Examples: GCC compiler, Python interpreter, Java SDK, Visual Studio.

142 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

142

  1. Program Loading and Execution:
    • Loaders and linkers to load compiled programs into memory for execution.
    • Examples: ld, absolute loaders, re-locatable loaders, and debugging systems.
  2. Communications:
    • Tools for creating connections between processes, users, and systems (e.g., messaging, web browsing, file transfer).
    • Examples: ssh, ftp, telnet, email clients, web browsers.

143 of 168

Operating system Design and Implementation

  • Two basic groups of requirements:
    1. User goals and
    2. System goals

User goals

  • The system should be
    • Convenient to use
    • Easy to learn and to use
    • Reliable, safe, and fast.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

143

144 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

144

System goals

The system should be

    • Easy to design, Implement, and maintain
    • Flexible, reliable, error free, and efficient.

145 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

145

Implementation

OS's are written in higher-level languages like C/C++

Advantages of higher-level languages:

    • Faster development and
    • OS is easier to port.

Disadvantages of higher-level languages:

    • Reduced speed and
    • Increased storage requirements.

146 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

146

Operating-System Structure

The OS is divided into a number of layers.

Each layer is built on the top of another layer.

The bottom layer is the hardware.

The highest is the user interface

A layer is made up of

    • Data and
    • Operations that can manipulate the data.

The layer consists of a set of routines that can be invoked by higher-layers.

147 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

147

Higher-layer

Do not need to know how lower-layer operations are implemented

Needs to know only what lower-layer operations do.

Advantages:

1) The layered approach is simple to construct and debug.

2) Simplifies debugging and system verification.

Disadvantages:

1) Appropriately defining the various layers is difficult as a layer can use only lower-level layers, careful planning is necessary.

2) Less efficient than other types.

148 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

148

Layered operating system.

149 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

149

Microkernels

  • Near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS).
  • Main function-provide a communication facility between client program and various services running in user-space.
  • Communication is provided by message passing.
  • All non-essential components are removed from the kernel and implemented as system- & user-programs.

150 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

150

Advantages:

1) Ease of extending the OS. (New services are added to user space w/o modification of kernel).

2) Easier to port from one hardware design to another.

3) Provides more security & reliability. (If a service fails, rest of the OS remains untouched.).

4) Provides minimal process and memory management.

Disadvantage:

1) Performance decreases due to increased system function overhead.

151 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

151

Architecture of a typical microkernel

152 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

152

Modules

  • The kernel has

∙ Σet of core components and

Dynamic links in additional services during boot time( or run time).

  • Seven types of modules in the kernel

153 of 168

  • The top layers include
    • Application environments and
    • Set of services providing a graphical interface to applications.
  • Kernel environment consists primarily of
    • Mach microkernel and
    • BSD kernel.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

153

154 of 168

Mach provides

    • Memory management;
    • Support for RPCs & IPC and
    • Thread scheduling.

BSD component provides

    • BSD command line interface
    • Support for networking and file systems and
    • Implementation of POSIX APIs

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

154

155 of 168

Virtual Machines

  • A virtual environment that functions as a separate computer with its own operating system.
  • Allows multiple operating systems to run concurrently on a single physical machine.
  • E.g VMware

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

155

156 of 168

  • The virtual-machine provides
  • Interface that is identical to the underlying hardware.
  • Copy of the underlying computer to each process.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

156

157 of 168

Benefits of virtual machine

  • Run Multiple OS Simultaneously
    • VMs allow sharing of hardware resources.
    • Different operating systems can run on the same hardware without conflict.
  • Enhanced Security
    • Host systems are protected from potential malware in guest VMs.
    • A virus in a VM typically won’t affect the host or other VMs.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

157

158 of 168

Resource Isolation

  • No direct sharing of resources between VMs.
  • Options for sharing file systems or creating a virtual network between VMs.

Ideal for OS Development

  • Virtual environments allow experimentation with operating system changes without affecting the host system.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

158

159 of 168

Developer Flexibility

  • Developers can test and run multiple operating systems concurrently on a single workstation.

Testing in Multiple Environments

    • QA engineers can run applications in different OS environments without the need for multiple physical machines.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

159

160 of 168

Data Center Efficiency

  • Consolidate multiple underutilized systems into fewer physical machines using VMs.
  • Achieves better resource optimization through physical-to-virtual conversion.

Why Use Virtual Machines?

    • Improve efficiency, security, and resource management.
    • Ideal for development, testing, and optimizing data center resources.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

160

161 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

161

VMware Architecture.

162 of 168

VMware Workstation: Virtualization of Intel X86 Hardware

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

162

  • Host OS: Linux
  • Guest OS: FreeBSD, Windows NT, Windows XP
  • Virtualization Layer: Abstracts physical hardware into isolated virtual machines.
  • Virtual CPU: Independently handles each VM's processing tasks
  • Virtual Memory: Each VM operates with its own allocated memory
  • Virtual Disk Drives: Simulated disk space for each VM
  • Virtual Network Interfaces: Independent network connectivity for each VM
  • Hardware abstraction allows multiple operating systems to run simultaneously on one physical machine.
  • Each guest OS operates in isolation from the others, ensuring stability and security.

163 of 168

Operating-System Generation (SYSGEN)

  • SYSGEN is the process of configuring an operating system for a specific computer site.
  • Operating systems must be adapted to run on various machines with different configurations.
  • Operating systems are distributed on disk, CD-ROM, DVD-ROM, or as ISO images.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

163

164 of 168

Key Information Required:

  • CPU: Type, options and for multi-CPU systems, each CPU’s details.
  • Boot Disk: Formatting, partitions, and their contents.
  • Memory: Amount of available memory, often determined by probing memory addresses.
  • Devices: Device number, interrupt number, type, and model.
  • Operating System Options: E.g., CPU scheduling algorithm, max number of processes, and buffer sizes.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

164

165 of 168

Approaches to System Generation:

  • Source Code Modification:
    • Admin modifies the OS source code for specific hardware.
    • Complete recompilation of the operating system.
    • Tailored but time-consuming.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

165

166 of 168

  • Precompiled Libraries:
    • Modules from precompiled libraries are selected based on system configuration.
    • Device drivers are linked in based on need.
    • Faster but results in a more general system.
  • Table-Driven Systems:
    • System components are selected at execution time.
    • SYSGEN simply involves creating appropriate tables.
    • Code is generalized but can adapt to hardware changes.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

166

167 of 168

System Boot

  • Booting means starting a computer by loading the kernel.
  • Bootstrap program is a code stored in ROM.
  • The bootstrap program
    • locates the kernel
    • loads the kernel into main memory and
    • Starts execution of kernel.
  • The bootstrap program can perform a variety of tasks.
  • One task is to run diagnostics to determine the state of the machine
  • OS must be made available to hardware so hardware can start it.

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

167

168 of 168

Latharani T R, Assistant Professor, Dept. of CS&E, JIT, Davangere

168